commit
3b3fea676a
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2007-present the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.nio.channels.*;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MavenWrapperDownloader {
|
||||
|
||||
private static final String WRAPPER_VERSION = "0.5.6";
|
||||
/**
|
||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
||||
*/
|
||||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
||||
|
||||
/**
|
||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
||||
* use instead of the default one.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||
".mvn/wrapper/maven-wrapper.properties";
|
||||
|
||||
/**
|
||||
* Path where the maven-wrapper.jar will be saved to.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
||||
".mvn/wrapper/maven-wrapper.jar";
|
||||
|
||||
/**
|
||||
* Name of the property which should be used to override the default download url for the wrapper.
|
||||
*/
|
||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("- Downloader started");
|
||||
File baseDirectory = new File(args[0]);
|
||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||
|
||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||
// wrapperUrl parameter.
|
||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||
String url = DEFAULT_DOWNLOAD_URL;
|
||||
if (mavenWrapperPropertyFile.exists()) {
|
||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||
try {
|
||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||
Properties mavenWrapperProperties = new Properties();
|
||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||
} catch (IOException e) {
|
||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||
} finally {
|
||||
try {
|
||||
if (mavenWrapperPropertyFileInputStream != null) {
|
||||
mavenWrapperPropertyFileInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Ignore ...
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading from: " + url);
|
||||
|
||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||
if (!outputFile.getParentFile().exists()) {
|
||||
if (!outputFile.getParentFile().mkdirs()) {
|
||||
System.out.println(
|
||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||
try {
|
||||
downloadFileFromURL(url, outputFile);
|
||||
System.out.println("Done");
|
||||
System.exit(0);
|
||||
} catch (Throwable e) {
|
||||
System.out.println("- Error downloading");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||
String username = System.getenv("MVNW_USERNAME");
|
||||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||
Authenticator.setDefault(new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
});
|
||||
}
|
||||
URL website = new URL(urlString);
|
||||
ReadableByteChannel rbc;
|
||||
rbc = Channels.newChannel(website.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(destination);
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
fos.close();
|
||||
rbc.close();
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
|
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>common</artifactId>
|
||||
<groupId>com.llw</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>common_utils</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- JWT-->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: ResultCode
|
||||
* Author: Caesar
|
||||
* Date: 2020-11-26 10:28
|
||||
* Description: 返回状态码
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.commonutils;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈返回状态码〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-11-26
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public enum ResultCode{
|
||||
SUCCESS(20000),ERROR(20001);
|
||||
private Integer code;
|
||||
private ResultCode(int code){
|
||||
this.code = code;
|
||||
}
|
||||
public int getCode(){
|
||||
return this.code;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: ExceptionUtil
|
||||
* Author: Caesar
|
||||
* Date: 2020-11-29 13:31
|
||||
* Description: 将日志信息输出到文件中
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.commonutils.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈将日志信息输出到文件中〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-11-29
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
public class ExceptionUtil {
|
||||
|
||||
public static String getMessage(Exception e) {
|
||||
StringWriter sw = null;
|
||||
PrintWriter pw = null;
|
||||
try {
|
||||
sw = new StringWriter();
|
||||
pw = new PrintWriter(sw);
|
||||
// 将出错的栈信息输出到printWriter中
|
||||
e.printStackTrace(pw);
|
||||
pw.flush();
|
||||
sw.flush();
|
||||
} finally {
|
||||
if (sw != null) {
|
||||
try {
|
||||
sw.close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (pw != null) {
|
||||
pw.close();
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: JwtUtils
|
||||
* Author: 李亮文
|
||||
* Date: 2020-12-22 12:49
|
||||
* Description: Jwt工具类
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.commonutils.util;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jws;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author
|
||||
*/
|
||||
public class JwtUtils {
|
||||
|
||||
public static final long EXPIRE = 1000 * 60 * 60 * 24;
|
||||
public static final String APP_SECRET = "ukc8BDbRigUDaY6pZFfWus2jZWLPHO";
|
||||
|
||||
public static String getJwtToken(String id, String nickname) {
|
||||
|
||||
String JwtToken = Jwts.builder()
|
||||
.setHeaderParam("typ", "JWT")
|
||||
.setHeaderParam("alg", "HS256")
|
||||
.setSubject("guli-user")
|
||||
.setIssuedAt(new Date())
|
||||
.setExpiration(new Date(System.currentTimeMillis() + EXPIRE))
|
||||
.claim("id", id)
|
||||
.claim("nickname", nickname)
|
||||
.signWith(SignatureAlgorithm.HS256, APP_SECRET)
|
||||
.compact();
|
||||
|
||||
return JwtToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断token是否存在与有效
|
||||
*
|
||||
* @param jwtToken
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkToken(String jwtToken) {
|
||||
if (StringUtils.isEmpty(jwtToken)) return false;
|
||||
try {
|
||||
Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断token是否存在与有效
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkToken(HttpServletRequest request) {
|
||||
try {
|
||||
String jwtToken = request.getHeader("token");
|
||||
if (StringUtils.isEmpty(jwtToken)) return false;
|
||||
Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据token获取会员id
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getMemberIdByJwtToken(HttpServletRequest request) {
|
||||
String jwtToken = request.getHeader("token");
|
||||
if (StringUtils.isEmpty(jwtToken)) return "";
|
||||
Jws<Claims> claimsJws = Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
|
||||
Claims claims = claimsJws.getBody();
|
||||
return (String) claims.get("id");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: R
|
||||
* Author: Caesar
|
||||
* Date: 2020-11-26 10:22
|
||||
* Description: 统一返回结果类
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.commonutils.vo;
|
||||
|
||||
import com.llw.commonutils.ResultCode;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈统一返回结果类〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-11-26
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class R {
|
||||
private boolean success;
|
||||
private int code;
|
||||
private String message;
|
||||
private Map<String,Object> data;
|
||||
|
||||
private R(){}
|
||||
|
||||
public static R ok(){
|
||||
R r = new R();
|
||||
r.setSuccess(true);
|
||||
r.setCode(ResultCode.SUCCESS.getCode());
|
||||
r.setMessage("成功");
|
||||
return r;
|
||||
}
|
||||
public static R error(){
|
||||
R r = new R();
|
||||
r.setSuccess(false);
|
||||
r.setCode(ResultCode.ERROR.getCode());
|
||||
r.setMessage("失败");
|
||||
return r;
|
||||
}
|
||||
public R success(Boolean success){
|
||||
this.setSuccess(success);
|
||||
return this;
|
||||
}
|
||||
|
||||
public R message(String message){
|
||||
this.setMessage(message);
|
||||
return this;
|
||||
}
|
||||
|
||||
public R code(Integer code){
|
||||
this.setCode(code);
|
||||
return this;
|
||||
}
|
||||
|
||||
public R data(Map<String,Object> data){
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
public R data(String key,Object value){
|
||||
if(data==null){
|
||||
data = new HashMap<>();
|
||||
}
|
||||
data.put(key,value);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>common</artifactId>
|
||||
<groupId>com.llw</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>service_base</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.llw</groupId>
|
||||
<artifactId>common_utils</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: RedisConfig
|
||||
* Author: 李亮文
|
||||
* Date: 2020-12-22 13:00
|
||||
* Description: Redis配置类
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.servicebase.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈Redis配置类〉
|
||||
*
|
||||
* @author 李亮文
|
||||
* @create 2020-12-22
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@EnableCaching
|
||||
@Configuration
|
||||
public class RedisConfig extends CachingConfigurerSupport {
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
RedisSerializer<String> redisSerializer = new StringRedisSerializer();
|
||||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||
template.setConnectionFactory(factory);
|
||||
//key序列化方式
|
||||
template.setKeySerializer(redisSerializer);
|
||||
//value序列化
|
||||
template.setValueSerializer(jackson2JsonRedisSerializer);
|
||||
//value hashmap序列化
|
||||
template.setHashValueSerializer(jackson2JsonRedisSerializer);
|
||||
return template;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CacheManager cacheManager(RedisConnectionFactory factory) {
|
||||
RedisSerializer<String> redisSerializer = new StringRedisSerializer();
|
||||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||
//解决查询缓存转换异常的问题
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||
// 配置序列化(解决乱码的问题),过期时间600秒
|
||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
|
||||
.entryTtl(Duration.ofSeconds(600))
|
||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer))
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer))
|
||||
.disableCachingNullValues();
|
||||
RedisCacheManager cacheManager = RedisCacheManager.builder(factory)
|
||||
.cacheDefaults(config)
|
||||
.build();
|
||||
return cacheManager;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: SwaggerConfig
|
||||
* Author: Caesar
|
||||
* Date: 2020-11-25 22:08
|
||||
* Description:
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.servicebase.config;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-11-25
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig {
|
||||
@Bean
|
||||
public Docket webApiConfig(){
|
||||
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("webApi")
|
||||
.apiInfo(webApiInfo())
|
||||
.select()
|
||||
.paths(Predicates.not(PathSelectors.regex("/admin/.*")))
|
||||
.paths(Predicates.not(PathSelectors.regex("/error.*")))
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
private ApiInfo webApiInfo(){
|
||||
|
||||
return new ApiInfoBuilder()
|
||||
.title("期末作业API文档")
|
||||
.description("本文档描述了课程中心微服务接口定义")
|
||||
.version("1.0")
|
||||
.contact(new Contact("Helen", "http://atguigu.com", "llw55230@gmail.com"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: MyException
|
||||
* Author: Caesar
|
||||
* Date: 2020-11-29 12:59
|
||||
* Description: 自定义异常类
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.servicebase.exception;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈自定义异常类〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-11-29
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MyException extends RuntimeException {
|
||||
@ApiModelProperty(value = "状态码")
|
||||
private Integer code;
|
||||
private String msg;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MyException{" +
|
||||
"code=" + code +
|
||||
", msg='" + msg + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: GlobalExceptionHandler
|
||||
* Author: Caesar
|
||||
* Date: 2020-11-29 12:52
|
||||
* Description: 统一异常处理类
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.servicebase.handler;
|
||||
|
||||
import com.llw.commonutils.util.ExceptionUtil;
|
||||
import com.llw.commonutils.vo.R;
|
||||
import com.llw.servicebase.exception.MyException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈统一异常处理类〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-11-29
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseBody
|
||||
public R error(Exception e){
|
||||
return R.error().message(e.getMessage());
|
||||
}
|
||||
@ExceptionHandler(MyException.class)
|
||||
@ResponseBody
|
||||
public R error(MyException e){
|
||||
log.error(ExceptionUtil.getMessage(e));
|
||||
return R.error().code(e.getCode()).message(e.getMsg());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: MyMetaObjectHandler
|
||||
* Author: Caesar
|
||||
* Date: 2020-11-27 08:12
|
||||
* Description:
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.servicebase.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈mybatis-plus自动填充〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-11-27
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Component
|
||||
public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("gmtCreate",new Date(),metaObject);
|
||||
this.setFieldValByName("gmtModified",new Date(),metaObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("gmtModified",new Date(),metaObject);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,310 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
else
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
fi
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if $cygwin; then
|
||||
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
else
|
||||
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl -o "$wrapperJarPath" "$jarUrl" -f
|
||||
else
|
||||
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
||||
fi
|
||||
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaClass=`cygpath --path --windows "$javaClass"`
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
@ -0,0 +1,182 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
|
||||
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
@ -0,0 +1,225 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>service</module>
|
||||
<module>common</module>
|
||||
</modules>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.1.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.llw</groupId>
|
||||
<artifactId>blue_stare</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>blue_stare</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<!--添加 <properties>确定依赖的版本-->
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<mybatis-plus.version>3.0.5</mybatis-plus.version>
|
||||
<velocity.version>2.0</velocity.version>
|
||||
<swagger.version>2.7.0</swagger.version>
|
||||
<aliyun.oss.version>2.8.3</aliyun.oss.version>
|
||||
<jodatime.version>2.10.1</jodatime.version>
|
||||
<poi.version>3.17</poi.version>
|
||||
<commons-fileupload.version>1.3.1</commons-fileupload.version>
|
||||
<commons-io.version>2.6</commons-io.version>
|
||||
<httpclient.version>4.5.1</httpclient.version>
|
||||
<jwt.version>0.7.0</jwt.version>
|
||||
<aliyun-java-sdk-core.version>4.3.3</aliyun-java-sdk-core.version>
|
||||
<aliyun-sdk-oss.version>3.1.0</aliyun-sdk-oss.version>
|
||||
<aliyun-java-sdk-vod.version>2.15.2</aliyun-java-sdk-vod.version>
|
||||
<aliyun-java-vod-upload.version>1.4.11</aliyun-java-vod-upload.version>
|
||||
<aliyun-sdk-vod-upload.version>1.4.11</aliyun-sdk-vod-upload.version>
|
||||
<fastjson.version>1.2.28</fastjson.version>
|
||||
<gson.version>2.8.2</gson.version>
|
||||
<json.version>20170516</json.version>
|
||||
<commons-dbutils.version>1.7</commons-dbutils.version>
|
||||
<canal.client.version>1.1.0</canal.client.version>
|
||||
<docker.image.prefix>zx</docker.image.prefix>
|
||||
<cloud-alibaba.version>0.2.2.RELEASE</cloud-alibaba.version>
|
||||
</properties>
|
||||
<!--配置 <dependencyManagement> 锁定依赖的版本-->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!--Spring Cloud-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Hoxton.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>${cloud-alibaba.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!--mybatis-plus 持久层-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- velocity 模板引擎, Mybatis Plus 代码生成器需要 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>${velocity.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--swagger-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
<!--swagger ui-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--aliyunOSS-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>${aliyun.oss.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--日期时间工具-->
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${jodatime.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--xls-->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<!--xlsx-->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--文件上传-->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${commons-fileupload.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--commons-io-->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--httpclient-->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${httpclient.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JWT -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--aliyun-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>${aliyun-java-sdk-core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>${aliyun-sdk-oss.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-vod</artifactId>
|
||||
<version>${aliyun-java-sdk-vod.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-vod-upload</artifactId>
|
||||
<version>${aliyun-java-vod-upload.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-sdk-vod-upload</artifactId>
|
||||
<version>${aliyun-sdk-vod-upload.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>${json.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-dbutils</groupId>
|
||||
<artifactId>commons-dbutils</artifactId>
|
||||
<version>${commons-dbutils.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.otter</groupId>
|
||||
<artifactId>canal.client</artifactId>
|
||||
<version>${canal.client.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<!-- 项目打包时会将java目录中的*.xml文件也进行打包 -->
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>service</artifactId>
|
||||
<groupId>com.llw</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>service_cms</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.llw</groupId>
|
||||
<artifactId>common_utils</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.llw</groupId>
|
||||
<artifactId>service_base</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: CmsApplication
|
||||
* Author: 李亮文
|
||||
* Date: 2020-12-20 21:22
|
||||
* Description: cms启动类
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.cms;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈cms启动类〉
|
||||
*
|
||||
* @author 李亮文
|
||||
* @create 2020-12-20
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@ComponentScan({"com.llw"})
|
||||
@MapperScan("com.llw.cms.mapper")
|
||||
public class CmsApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CmsApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
package com.llw.cms.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.llw.cms.domain.CrmBanner;
|
||||
import com.llw.cms.service.CrmBannerService;
|
||||
import com.llw.commonutils.vo.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 首页banner表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-20
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/cms/adminBanner")
|
||||
public class CrmBannerAdminController {
|
||||
@Autowired
|
||||
private CrmBannerService crmBannerService;
|
||||
|
||||
/**
|
||||
* 增加
|
||||
* @param crmBanner
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public R addBanner(@RequestBody CrmBanner crmBanner){
|
||||
crmBannerService.saveBanner(crmBanner);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("delete/{id}")
|
||||
public R removeById(@PathVariable String id){
|
||||
crmBannerService.removeBannerById(id);
|
||||
return R.ok();
|
||||
}
|
||||
@PutMapping("update")
|
||||
public R update(@RequestBody CrmBanner crmBanner){
|
||||
crmBannerService.updateBannerById(crmBanner);
|
||||
return R.ok();
|
||||
}
|
||||
@PostMapping("pageList/{page}/{limit}")
|
||||
public R pageList(@PathVariable long page,@PathVariable long limit){
|
||||
Page p = new Page(page,limit);
|
||||
crmBannerService.pageBanner(p,null);
|
||||
return R.ok().data("items",p.getRecords()).data("total",p.getTotal());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
package com.llw.cms.controller;
|
||||
|
||||
|
||||
import com.llw.cms.domain.CrmBanner;
|
||||
import com.llw.cms.service.CrmBannerService;
|
||||
import com.llw.commonutils.vo.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 首页banner表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-20
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/cms/homeBanner")
|
||||
public class CrmBannerHomeController {
|
||||
@Autowired
|
||||
private CrmBannerService crmBannerService;
|
||||
|
||||
@GetMapping("getBannerList")
|
||||
public R getBannerList(){
|
||||
List<CrmBanner> list = crmBannerService.selectIndexList();
|
||||
return R.ok().data("items",list);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package com.llw.cms.mapper;
|
||||
|
||||
import com.llw.cms.domain.CrmBanner;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 首页banner表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-20
|
||||
*/
|
||||
public interface CrmBannerMapper extends BaseMapper<CrmBanner> {
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.llw.cms.mapper.CrmBannerMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,37 @@
|
||||
package com.llw.cms.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.llw.cms.domain.CrmBanner;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 首页banner表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-20
|
||||
*/
|
||||
public interface CrmBannerService extends IService<CrmBanner> {
|
||||
|
||||
|
||||
@Cacheable(value = "banner", key = "'selectIndexList'")
|
||||
List<CrmBanner> selectIndexList();
|
||||
|
||||
void pageBanner(Page<CrmBanner> pageParam, Object o);
|
||||
|
||||
CrmBanner getBannerById(String id);
|
||||
|
||||
@CacheEvict(value = "banner", allEntries=true)
|
||||
void saveBanner(CrmBanner banner);
|
||||
|
||||
@CacheEvict(value = "banner", allEntries=true)
|
||||
void updateBannerById(CrmBanner banner);
|
||||
|
||||
@CacheEvict(value = "banner", allEntries=true)
|
||||
void removeBannerById(String id);
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.llw.cms.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.llw.cms.domain.CrmBanner;
|
||||
import com.llw.cms.mapper.CrmBannerMapper;
|
||||
import com.llw.cms.service.CrmBannerService;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 首页banner表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-20
|
||||
*/
|
||||
@Service
|
||||
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner> implements CrmBannerService {
|
||||
|
||||
|
||||
|
||||
@Cacheable(value = "banner", key = "'selectIndexList'")
|
||||
@Override
|
||||
public List<CrmBanner> selectIndexList() {
|
||||
List<CrmBanner> list = baseMapper.selectList(new QueryWrapper<CrmBanner>().orderByDesc("sort"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pageBanner(Page<CrmBanner> pageParam, Object o) {
|
||||
baseMapper.selectPage(pageParam,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CrmBanner getBannerById(String id) {
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
@CacheEvict(value = "banner", allEntries=true)
|
||||
@Override
|
||||
public void saveBanner(CrmBanner banner) {
|
||||
baseMapper.insert(banner);
|
||||
}
|
||||
|
||||
@CacheEvict(value = "banner", allEntries=true)
|
||||
@Override
|
||||
public void updateBannerById(CrmBanner banner) {
|
||||
baseMapper.updateById(banner);
|
||||
}
|
||||
|
||||
@CacheEvict(value = "banner", allEntries=true)
|
||||
@Override
|
||||
public void removeBannerById(String id) {
|
||||
baseMapper.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
# 服务端口
|
||||
server.port=8004
|
||||
# 服务名
|
||||
spring.application.name=service-cms
|
||||
|
||||
# mysql数据库连接
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/blue_star?serverTimezone=GMT%2B8
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=mysqladmin
|
||||
|
||||
#返回json的全局时间格式
|
||||
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
|
||||
spring.jackson.time-zone=GMT+8
|
||||
|
||||
#配置mapper xml文件的路径
|
||||
mybatis-plus.mapper-locations=classpath:com/llw/cms/mapper/xml/*.xml
|
||||
|
||||
#mybatis日志
|
||||
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
# nacos服务地址
|
||||
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
|
||||
|
||||
#redis
|
||||
spring.redis.host=192.168.249.129
|
||||
spring.redis.port=6379
|
||||
spring.redis.database= 0
|
||||
spring.redis.timeout=1800000
|
||||
|
||||
spring.redis.lettuce.pool.max-active=20
|
||||
spring.redis.lettuce.pool.max-wait=-1
|
||||
#最大阻塞等待时间(负数表示没限制)
|
||||
spring.redis.lettuce.pool.max-idle=5
|
||||
spring.redis.lettuce.pool.min-idle=0
|
@ -0,0 +1,77 @@
|
||||
package com.llw.test.cms;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.PackageConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 2018/12/13
|
||||
*/
|
||||
public class CodeGenerator {
|
||||
|
||||
@Test
|
||||
public void run() {
|
||||
|
||||
// 1、创建代码生成器
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
// 2、全局配置
|
||||
GlobalConfig gc = new GlobalConfig();
|
||||
// String projectPath = System.getProperty("user.dir");
|
||||
gc.setOutputDir("E:\\Java\\blue_stare\\service\\service_cms" + "/src/main/java");
|
||||
gc.setAuthor("李亮文");
|
||||
gc.setOpen(false); //生成后是否打开资源管理器
|
||||
gc.setFileOverride(false); //重新生成时文件是否覆盖
|
||||
gc.setServiceName("%sService"); //去掉Service接口的首字母I
|
||||
gc.setIdType(IdType.ID_WORKER_STR); //主键策略
|
||||
gc.setDateType(DateType.ONLY_DATE);//定义生成的实体类中日期类型
|
||||
gc.setSwagger2(true);//开启Swagger2模式
|
||||
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
// 3、数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setUrl("jdbc:mysql://localhost:3306/blue_star?serverTimezone=GMT%2B8");
|
||||
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
|
||||
dsc.setUsername("root");
|
||||
dsc.setPassword("mysqladmin");
|
||||
dsc.setDbType(DbType.MYSQL);
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
// 4、包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
pc.setModuleName("cms"); //模块名
|
||||
pc.setParent("com.llw");
|
||||
pc.setController("controller");
|
||||
pc.setEntity("domain");
|
||||
pc.setService("service");
|
||||
pc.setMapper("mapper");
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
// 5、策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setInclude("crm_banner");
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
|
||||
strategy.setTablePrefix(pc.getModuleName() + "_"); //生成实体时去掉表前缀
|
||||
|
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);//数据库表字段映射到实体的命名策略
|
||||
strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作
|
||||
|
||||
strategy.setRestControllerStyle(true); //restful api风格控制器
|
||||
strategy.setControllerMappingHyphenStyle(true); //url中驼峰转连字符
|
||||
|
||||
mpg.setStrategy(strategy);
|
||||
|
||||
|
||||
// 6、执行
|
||||
mpg.execute();
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>service</artifactId>
|
||||
<groupId>com.llw</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>service_edu</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.llw</groupId>
|
||||
<artifactId>common_utils</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.llw</groupId>
|
||||
<artifactId>service_base</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: EduApplication
|
||||
* Author: Caesar
|
||||
* Date: 2020-11-25 15:11
|
||||
* Description:
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.eduservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-11-25
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient //服务注册
|
||||
@EnableFeignClients //服务调用
|
||||
@ComponentScan(basePackages = {"com.llw"})
|
||||
public class EduApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(EduApplication.class,args);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: VodClient
|
||||
* Author: 李亮文
|
||||
* Date: 2020-12-18 23:25
|
||||
* Description: 视频客户端
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.eduservice.client;
|
||||
|
||||
import com.llw.commonutils.vo.R;
|
||||
import com.llw.eduservice.client.impl.VodFileDegradeFeignClient;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈视频客户端〉
|
||||
*
|
||||
* @author 李亮文
|
||||
* @create 2020-12-18
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@FeignClient(name = "service-vod",fallback = VodFileDegradeFeignClient.class)
|
||||
@Component
|
||||
public interface VodClient {
|
||||
//删除一个视频
|
||||
@DeleteMapping("/eduvod/video/delete/{videoId}")
|
||||
public R deleteById(@PathVariable("videoId") String videoId);
|
||||
|
||||
//删除多个视频
|
||||
@DeleteMapping(value = "/eduvod/video/delete")
|
||||
public R deleteByIds(@RequestParam("videoIds") List<String> videoIds);
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: VodFileDegradeFeignClient
|
||||
* Author: 李亮文
|
||||
* Date: 2020-12-19 13:34
|
||||
* Description: 熔断器
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.eduservice.client.impl;
|
||||
|
||||
import com.llw.commonutils.vo.R;
|
||||
import com.llw.eduservice.client.VodClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈熔断器〉
|
||||
*
|
||||
* @author 李亮文
|
||||
* @create 2020-12-19
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Component
|
||||
public class VodFileDegradeFeignClient implements VodClient {
|
||||
|
||||
@Override
|
||||
public R deleteById(String videoId) {
|
||||
return R.error();
|
||||
}
|
||||
|
||||
@Override
|
||||
public R deleteByIds(List<String> videoIds) {
|
||||
return R.error();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.llw.eduservice.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 评论 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/eduservice/edu-comment")
|
||||
public class EduCommentController {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.llw.eduservice.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程收藏 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/eduservice/edu-course-collect")
|
||||
public class EduCourseCollectController {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,129 @@
|
||||
package com.llw.eduservice.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.llw.commonutils.vo.R;
|
||||
import com.llw.eduservice.domain.EduCourse;
|
||||
import com.llw.eduservice.domain.EduCourseDescription;
|
||||
import com.llw.eduservice.domain.query.HomeCourseQuery;
|
||||
import com.llw.eduservice.domain.vo.CourseInfo;
|
||||
import com.llw.eduservice.domain.vo.CourseInfoForm;
|
||||
import com.llw.eduservice.domain.vo.CourseQuery;
|
||||
import com.llw.eduservice.service.EduCourseService;
|
||||
import com.llw.eduservice.service.impl.EduCourseDescriptionServiceImpl;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/eduservice/course")
|
||||
@CrossOrigin
|
||||
public class EduCourseController {
|
||||
@Autowired
|
||||
private EduCourseService eduCourseService;
|
||||
|
||||
@Autowired
|
||||
private EduCourseDescriptionServiceImpl descriptionService;
|
||||
@PostMapping("save")
|
||||
public R save(@RequestBody CourseInfoForm courseInfo){
|
||||
String id = eduCourseService.saveCourseInfo(courseInfo);
|
||||
return R.ok().data("id",id);
|
||||
}
|
||||
@GetMapping("find/{courseId}")
|
||||
public R getCourseByCourseId(
|
||||
@ApiParam(value = "课程id")
|
||||
@PathVariable String courseId
|
||||
){
|
||||
CourseInfoForm courseInfoForm = eduCourseService.getCourseVo(courseId);
|
||||
return R.ok().data("item",courseInfoForm);
|
||||
}
|
||||
@ApiOperation(value = "更新课程及其简介")
|
||||
@PutMapping("{courseId}")
|
||||
public R updateCourse(
|
||||
@PathVariable String courseId,
|
||||
@RequestBody CourseInfoForm courseInfoForm
|
||||
){
|
||||
eduCourseService.updateCourseAndDes(courseId,courseInfoForm);
|
||||
return R.ok();
|
||||
}
|
||||
@PostMapping("getCourseInfo/{courseId}")
|
||||
public R getCourseInfo(
|
||||
@PathVariable String courseId
|
||||
){
|
||||
CourseInfo courseInfo = eduCourseService.getCourseInfo(courseId);
|
||||
return courseInfo==null ? R.error() : R.ok().data("item",courseInfo);
|
||||
}
|
||||
@GetMapping("getCourse/{courseId}")
|
||||
public R getCourse(
|
||||
@PathVariable String courseId
|
||||
){
|
||||
EduCourse eduCourse = eduCourseService.getById(courseId);
|
||||
return eduCourse==null ? R.error() : R.ok().data("item",eduCourse);
|
||||
}
|
||||
@ApiOperation(value = "分页课程列表")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public R pageQuery(
|
||||
@ApiParam(name = "page", value = "当前页码", required = true)
|
||||
@PathVariable Long page,
|
||||
|
||||
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||
@PathVariable Long limit,
|
||||
|
||||
@ApiParam(name = "courseQuery", value = "查询对象", required = false)
|
||||
CourseQuery courseQuery){
|
||||
return eduCourseService.pageList(page,limit,courseQuery);
|
||||
}
|
||||
@DeleteMapping("delete/{id}")
|
||||
public R delete(
|
||||
@PathVariable String id
|
||||
){
|
||||
eduCourseService.deleteById(id);
|
||||
return R.ok();
|
||||
}
|
||||
@GetMapping("getHotCourse")
|
||||
public R getHotCourse(){
|
||||
QueryWrapper<EduCourse> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("status","Normal");
|
||||
wrapper.orderByDesc("view_count","buy_count","gmt_create");
|
||||
wrapper.last("limit 8");
|
||||
List<EduCourse> list = eduCourseService.list(wrapper);
|
||||
return R.ok().data("items",list);
|
||||
}
|
||||
@ApiOperation(value = "前台分页课程列表")
|
||||
@GetMapping("pageList/{page}/{limit}")
|
||||
public R pageList(
|
||||
@ApiParam(name = "page", value = "当前页码", required = true)
|
||||
@PathVariable Long page,
|
||||
|
||||
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||
@PathVariable Long limit,
|
||||
|
||||
@ApiParam(name = "courseQuery", value = "查询对象", required = false)
|
||||
HomeCourseQuery courseQuery){
|
||||
return eduCourseService.homePageList(page,limit,courseQuery);
|
||||
}
|
||||
@GetMapping("getDes/{courseId}")
|
||||
public R getDesc(@PathVariable String courseId){
|
||||
EduCourseDescription eduCourseDescription = descriptionService.getById(courseId);
|
||||
return R.ok().data("item",eduCourseDescription);
|
||||
}
|
||||
@GetMapping("getCourseByTeacherId/{teacherId}")
|
||||
public R getCourseByTeacherId(@PathVariable String teacherId){
|
||||
QueryWrapper<EduCourse> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("teacher_id",teacherId);
|
||||
List<EduCourse> courses = eduCourseService.list(wrapper);
|
||||
return R.ok().data("items",courses);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: EduLoginController
|
||||
* Author: Caesar
|
||||
* Date: 2020-11-30 23:16
|
||||
* Description: 登录控制器
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.eduservice.controller;
|
||||
|
||||
import com.llw.commonutils.vo.R;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈登录控制器〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-11-30
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("eduservice/user")
|
||||
@CrossOrigin
|
||||
public class EduLoginController {
|
||||
|
||||
@PostMapping("login")
|
||||
public R login(){
|
||||
return R.ok().data("token","admin");
|
||||
}
|
||||
@GetMapping("info")
|
||||
public R info(){
|
||||
return R.ok().data("roles","[admin]").data("name","admin").data("avatar","https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3432627115,2855394237&fm=26&gp=0.jpg");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.llw.eduservice.controller;
|
||||
|
||||
|
||||
import com.llw.commonutils.vo.R;
|
||||
import com.llw.eduservice.domain.vo.SubjectData;
|
||||
import com.llw.eduservice.service.EduSubjectService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程科目 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/eduservice/subject")
|
||||
@CrossOrigin
|
||||
public class EduSubjectController {
|
||||
@Autowired
|
||||
private EduSubjectService subjectService;
|
||||
|
||||
@PostMapping("add")
|
||||
public R save(MultipartFile file){
|
||||
subjectService.save(file);
|
||||
return R.ok();
|
||||
}
|
||||
@PostMapping("list")
|
||||
public R getSubjectTree(){
|
||||
List<SubjectData> subjectDataList = subjectService.getSubjectTree();
|
||||
return R.ok().data("items",subjectDataList);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,100 @@
|
||||
package com.llw.eduservice.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.llw.commonutils.vo.R;
|
||||
import com.llw.eduservice.domain.EduTeacher;
|
||||
import com.llw.eduservice.query.TeacherQuery;
|
||||
import com.llw.eduservice.service.EduTeacherService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 讲师 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-11-25
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/eduservice/teacher")
|
||||
@Api("高级讲师管理")
|
||||
public class EduTeacherController {
|
||||
@Autowired
|
||||
private EduTeacherService eduTeacherService;
|
||||
|
||||
@ApiOperation("查询所有讲师")
|
||||
@GetMapping("findAll")
|
||||
public R findAll(){
|
||||
List<EduTeacher> list = eduTeacherService.list(null);
|
||||
return list!=null ? R.ok().data("items",list) : R.error();
|
||||
}
|
||||
|
||||
@DeleteMapping("delete/{id}")
|
||||
@ApiOperation("根据ID删除讲师")
|
||||
public R removeById(
|
||||
@ApiParam(name="id",value = "讲师id",required = true) @PathVariable String id
|
||||
){
|
||||
return eduTeacherService.removeById(id) ? R.ok() : R.error();
|
||||
}
|
||||
@ApiOperation(value = "分页讲师列表")
|
||||
@PostMapping("getTeacherListByOption/{page}/{limit}")
|
||||
public R pageList(
|
||||
@ApiParam(name = "page", value = "当前页码", required = true)
|
||||
@PathVariable Long page,
|
||||
|
||||
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||
@PathVariable Long limit,
|
||||
|
||||
@ApiParam(name = "teacherQuery", value = "查询对象", required = true)
|
||||
@RequestBody(required = false) TeacherQuery teacherQuery
|
||||
){
|
||||
return eduTeacherService.pageList(page,limit,teacherQuery);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增讲师")
|
||||
@PostMapping("save")
|
||||
public R save(
|
||||
@ApiParam(name = "teacher",value = "讲师信息",required = true)
|
||||
@RequestBody EduTeacher teacher
|
||||
){
|
||||
boolean save = eduTeacherService.save(teacher);
|
||||
return save ? R.ok() : R.error();
|
||||
}
|
||||
@ApiOperation("根据讲师id查询讲师")
|
||||
@GetMapping("{id}")
|
||||
public R findOne(
|
||||
@ApiParam(name = "id",value = "讲师id",required = true)
|
||||
@PathVariable String id
|
||||
){
|
||||
EduTeacher teacher = eduTeacherService.getById(id);
|
||||
return teacher!=null ? R.ok().data("item",teacher) : R.error();
|
||||
}
|
||||
@ApiOperation("根据id修改讲师")
|
||||
@PutMapping("update")
|
||||
public R update(
|
||||
@ApiParam(name = "teacher",value = "讲师对象",required = true)
|
||||
@RequestBody EduTeacher teacher
|
||||
){
|
||||
boolean b = eduTeacherService.updateById(teacher);
|
||||
return b ? R.ok(): R.error();
|
||||
}
|
||||
@GetMapping("getHotTeacher")
|
||||
public R getHotTeacher(){
|
||||
QueryWrapper<EduTeacher> wrapper = new QueryWrapper<>();
|
||||
wrapper.orderByDesc("sort");
|
||||
wrapper.last("limit 4");
|
||||
List<EduTeacher> list = eduTeacherService.list(wrapper);
|
||||
return R.ok().data("items",list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.llw.eduservice.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程视频 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/eduservice/edu-video")
|
||||
public class EduVideoController {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.llw.eduservice.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="EduChapter对象", description="课程")
|
||||
public class EduChapter implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "章节ID")
|
||||
@TableId(value = "id", type = IdType.ID_WORKER_STR)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "课程ID")
|
||||
private String courseId;
|
||||
|
||||
@ApiModelProperty(value = "章节名称")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "显示排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date gmtCreate;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date gmtModified;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.llw.eduservice.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程简介
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="EduCourseDescription对象", description="课程简介")
|
||||
public class EduCourseDescription implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "课程ID")
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "课程简介")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date gmtCreate;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date gmtModified;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.llw.eduservice.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程科目
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="EduSubject对象", description="课程科目")
|
||||
public class EduSubject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "课程类别ID")
|
||||
@TableId(value = "id", type = IdType.ID_WORKER_STR)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "类别名称")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "父ID")
|
||||
private String parentId;
|
||||
|
||||
@ApiModelProperty(value = "排序字段")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date gmtCreate;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date gmtModified;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: Subject
|
||||
* Author: Caesar
|
||||
* Date: 2020-12-05 14:44
|
||||
* Description:
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.eduservice.domain.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-12-05
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class Subject {
|
||||
@ExcelProperty(index = 0)
|
||||
private String oneSubject;
|
||||
|
||||
//设置列对应的属性
|
||||
@ExcelProperty(index = 1)
|
||||
private String twoSubject;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: HomeCourseQuery
|
||||
* Author: 李亮文
|
||||
* Date: 2020-12-21 19:35
|
||||
* Description: 前台系统查询对象
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.eduservice.domain.query;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈前台系统查询对象〉
|
||||
*
|
||||
* @author 李亮文
|
||||
* @create 2020-12-21
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class HomeCourseQuery {
|
||||
|
||||
@ApiModelProperty(value = "二级类别id")
|
||||
private String subjectId;
|
||||
|
||||
private boolean viewCount;
|
||||
|
||||
private int price;
|
||||
|
||||
private boolean gmtCreate;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: ChapterVo
|
||||
* Author: Caesar
|
||||
* Date: 2020-12-07 23:04
|
||||
* Description: 章节前端显示
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.eduservice.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈章节前端显示〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-12-07
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class ChapterVo{
|
||||
//章节id
|
||||
private String id;
|
||||
//章节名称
|
||||
private String title;
|
||||
//章节所包含的小节
|
||||
private List<VideoVo> children = new ArrayList<>();
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: CourseQuery
|
||||
* Author: 李亮文
|
||||
* Date: 2020-12-12 00:13
|
||||
* Description: 查询对象
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.eduservice.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈查询对象〉
|
||||
*
|
||||
* @author 李亮文
|
||||
* @create 2020-12-12
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@ApiModel(value = "Course查询对象", description = "课程查询对象封装")
|
||||
@Data
|
||||
public class CourseQuery implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "课程名称")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "讲师id")
|
||||
private String teacherId;
|
||||
|
||||
@ApiModelProperty(value = "一级类别id")
|
||||
private String subjectParentId;
|
||||
|
||||
@ApiModelProperty(value = "二级类别id")
|
||||
private String subjectId;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: SubjectData
|
||||
* Author: Caesar
|
||||
* Date: 2020-12-05 16:04
|
||||
* Description:
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.eduservice.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-12-05
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class SubjectData {
|
||||
private String id;
|
||||
private String title;
|
||||
private List<SubjectData> children;
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: VideoVo
|
||||
* Author: 李亮文
|
||||
* Date: 2020-12-07 23:04
|
||||
* Description: 小节前端显示
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.eduservice.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈小节前端显示〉
|
||||
*
|
||||
* @author李亮文
|
||||
* @create 2020-12-07
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class VideoVo {
|
||||
private String id;
|
||||
private String title;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: ExcelListener
|
||||
* Author: Caesar
|
||||
* Date: 2020-12-05 14:55
|
||||
* Description:
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.eduservice.listener;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.llw.eduservice.domain.EduSubject;
|
||||
import com.llw.eduservice.domain.excel.Subject;
|
||||
import com.llw.eduservice.mapper.EduSubjectMapper;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-12-05
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class ExcelListener extends AnalysisEventListener<Subject> {
|
||||
|
||||
private EduSubjectMapper mapper;
|
||||
|
||||
public ExcelListener() {}
|
||||
|
||||
public ExcelListener(EduSubjectMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(Subject subject, AnalysisContext analysisContext) {
|
||||
EduSubject eduSubject = findOneByName(subject.getOneSubject(), "0");
|
||||
if(eduSubject==null){
|
||||
eduSubject = new EduSubject();
|
||||
eduSubject.setParentId("0");
|
||||
eduSubject.setTitle(subject.getOneSubject());
|
||||
mapper.insert(eduSubject);
|
||||
}
|
||||
String pid = eduSubject.getId();
|
||||
EduSubject eduSubject1 = findOneByName(subject.getTwoSubject(),pid);
|
||||
if(eduSubject1==null){
|
||||
eduSubject1 = new EduSubject();
|
||||
eduSubject1.setParentId(pid);
|
||||
eduSubject1.setTitle(subject.getTwoSubject());
|
||||
mapper.insert(eduSubject1);
|
||||
}
|
||||
}
|
||||
//判断课程分类是否在数据库中
|
||||
private EduSubject findOneByName(String name,String pid){
|
||||
QueryWrapper<EduSubject> wrapper = new QueryWrapper<>();
|
||||
if(!("0".equals(pid))){
|
||||
wrapper.eq("parent_id",pid);
|
||||
}
|
||||
wrapper.eq("title",name);
|
||||
EduSubject eduSubject = mapper.selectOne(wrapper);
|
||||
return eduSubject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.llw.eduservice.mapper;
|
||||
|
||||
import com.llw.eduservice.domain.EduChapter;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@Component
|
||||
public interface EduChapterMapper extends BaseMapper<EduChapter> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.llw.eduservice.mapper;
|
||||
|
||||
import com.llw.eduservice.domain.EduComment;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 评论 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-14
|
||||
*/
|
||||
@Component
|
||||
public interface EduCommentMapper extends BaseMapper<EduComment> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.llw.eduservice.mapper;
|
||||
|
||||
import com.llw.eduservice.domain.EduCourseCollect;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程收藏 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-14
|
||||
*/
|
||||
@Component
|
||||
public interface EduCourseCollectMapper extends BaseMapper<EduCourseCollect> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.llw.eduservice.mapper;
|
||||
|
||||
import com.llw.eduservice.domain.EduCourseDescription;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程简介 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@Component
|
||||
public interface EduCourseDescriptionMapper extends BaseMapper<EduCourseDescription> {
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.llw.eduservice.mapper;
|
||||
|
||||
import com.llw.eduservice.domain.EduCourse;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.llw.eduservice.domain.vo.CourseInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@Component
|
||||
public interface EduCourseMapper extends BaseMapper<EduCourse> {
|
||||
|
||||
CourseInfo getCourseInfo(String courseId);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.llw.eduservice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.llw.eduservice.domain.EduSubject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程科目 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-05
|
||||
*/
|
||||
@Component
|
||||
public interface EduSubjectMapper extends BaseMapper<EduSubject> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.llw.eduservice.mapper;
|
||||
|
||||
import com.llw.eduservice.domain.EduTeacher;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 讲师 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-11-25
|
||||
*/
|
||||
@Component
|
||||
public interface EduTeacherMapper extends BaseMapper<EduTeacher> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.llw.eduservice.mapper;
|
||||
|
||||
import com.llw.eduservice.domain.EduVideo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程视频 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@Component
|
||||
public interface EduVideoMapper extends BaseMapper<EduVideo> {
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.llw.eduservice.mapper.EduChapterMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.llw.eduservice.mapper.EduCommentMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.llw.eduservice.mapper.EduCourseCollectMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.llw.eduservice.mapper.EduCourseDescriptionMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.llw.eduservice.mapper.EduCourseMapper">
|
||||
|
||||
<select id="getCourseInfo" resultType="com.llw.eduservice.domain.vo.CourseInfo">
|
||||
SELECT
|
||||
c.title courseTitle,
|
||||
c.price,
|
||||
c.lesson_num,
|
||||
des.description,
|
||||
teacher.name teacherName,
|
||||
one.title parentSubject,
|
||||
two.title subject,
|
||||
c.cover
|
||||
FROM edu_course c
|
||||
left join edu_course_description des
|
||||
on c.id=des.id
|
||||
left join edu_teacher teacher
|
||||
on c.teacher_id=teacher.id
|
||||
left join edu_subject one
|
||||
on c.subject_parent_id=one.id
|
||||
left join edu_subject two
|
||||
on c.subject_id=two.id
|
||||
where c.id=#{courseId};
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.llw.eduservice.mapper.EduSubjectMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.llw.eduservice.mapper.EduTeacherMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.llw.eduservice.mapper.EduVideoMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,25 @@
|
||||
package com.llw.eduservice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.llw.eduservice.domain.EduChapter;
|
||||
import com.llw.eduservice.domain.vo.ChapterVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
public interface EduChapterService extends IService<EduChapter> {
|
||||
List<ChapterVo> nestedList(String courseId);
|
||||
|
||||
void addChapter(String courseId, List<ChapterVo> chapterVo);
|
||||
|
||||
void deleteChapterAndVideoByChapterId(String chapterId);
|
||||
|
||||
void deleteVideoById(String videoId);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.llw.eduservice.service;
|
||||
|
||||
import com.llw.eduservice.domain.EduComment;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 评论 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-14
|
||||
*/
|
||||
public interface EduCommentService extends IService<EduComment> {
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.llw.eduservice.service;
|
||||
|
||||
import com.llw.eduservice.domain.EduCourseCollect;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程收藏 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-14
|
||||
*/
|
||||
public interface EduCourseCollectService extends IService<EduCourseCollect> {
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.llw.eduservice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.llw.commonutils.vo.R;
|
||||
import com.llw.eduservice.domain.EduCourse;
|
||||
import com.llw.eduservice.domain.query.HomeCourseQuery;
|
||||
import com.llw.eduservice.domain.vo.CourseInfo;
|
||||
import com.llw.eduservice.domain.vo.CourseInfoForm;
|
||||
import com.llw.eduservice.domain.vo.CourseQuery;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
public interface EduCourseService extends IService<EduCourse> {
|
||||
|
||||
|
||||
String saveCourseInfo(CourseInfoForm courseInfo);
|
||||
|
||||
CourseInfoForm getCourseVo(String courseId);
|
||||
|
||||
void updateCourseAndDes(String courseId, CourseInfoForm courseInfoForm);
|
||||
|
||||
CourseInfo getCourseInfo(String courseId);
|
||||
|
||||
R pageList(Long page, Long limit, CourseQuery courseQuery);
|
||||
|
||||
R homePageList(Long page, Long limit, HomeCourseQuery homeCourseQuery);
|
||||
|
||||
void deleteById(String id);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.llw.eduservice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.llw.eduservice.domain.EduSubject;
|
||||
import com.llw.eduservice.domain.vo.SubjectData;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程科目 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-05
|
||||
*/
|
||||
public interface EduSubjectService extends IService<EduSubject> {
|
||||
|
||||
void save(MultipartFile file);
|
||||
|
||||
List<SubjectData> getSubjectTree();
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.llw.eduservice.service;
|
||||
|
||||
import com.llw.commonutils.vo.R;
|
||||
import com.llw.eduservice.domain.EduTeacher;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.llw.eduservice.query.TeacherQuery;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 讲师 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-11-25
|
||||
*/
|
||||
public interface EduTeacherService extends IService<EduTeacher> {
|
||||
|
||||
R pageList(long page, long limit, TeacherQuery teacherQuery);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.llw.eduservice.service;
|
||||
|
||||
import com.llw.eduservice.domain.EduVideo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程视频 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
public interface EduVideoService extends IService<EduVideo> {
|
||||
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package com.llw.eduservice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.llw.commonutils.vo.R;
|
||||
import com.llw.eduservice.client.VodClient;
|
||||
import com.llw.eduservice.domain.EduChapter;
|
||||
import com.llw.eduservice.domain.EduVideo;
|
||||
import com.llw.eduservice.domain.vo.ChapterVo;
|
||||
import com.llw.eduservice.domain.vo.VideoVo;
|
||||
import com.llw.eduservice.mapper.EduChapterMapper;
|
||||
import com.llw.eduservice.service.EduChapterService;
|
||||
import com.llw.eduservice.service.EduVideoService;
|
||||
import com.llw.servicebase.exception.MyException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@Service
|
||||
public class EduChapterServiceImpl extends ServiceImpl<EduChapterMapper, EduChapter> implements EduChapterService {
|
||||
@Autowired
|
||||
private EduVideoService eduVideoService;
|
||||
@Autowired
|
||||
private VodClient vodClient;
|
||||
|
||||
@Override
|
||||
public List<ChapterVo> nestedList(String courseId) {
|
||||
QueryWrapper<EduChapter> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("course_id", courseId);
|
||||
wrapper.orderByAsc("sort");
|
||||
List<EduChapter> eduChapters = baseMapper.selectList(wrapper);
|
||||
List<ChapterVo> chapterVos = new ArrayList<>();
|
||||
for (EduChapter e : eduChapters) {
|
||||
ChapterVo chapterVo = new ChapterVo();
|
||||
chapterVo.setId(e.getId());
|
||||
chapterVo.setTitle(e.getTitle());
|
||||
//获取小节
|
||||
QueryWrapper<EduVideo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("course_id", courseId);
|
||||
queryWrapper.eq("chapter_id", e.getId());
|
||||
queryWrapper.orderByAsc("sort ");
|
||||
List<EduVideo> eduVideos = eduVideoService.list(queryWrapper);
|
||||
List<VideoVo> videoVos = new ArrayList<>();
|
||||
//将查出来的小节放到vo对象中
|
||||
for (EduVideo v : eduVideos) {
|
||||
VideoVo videoVo = new VideoVo();
|
||||
videoVo.setId(v.getId());
|
||||
videoVo.setTitle(v.getTitle());
|
||||
videoVos.add(videoVo);
|
||||
}
|
||||
//将小节vo对象装载到章节vo对象中
|
||||
chapterVo.setChildren(videoVos);
|
||||
//将章节对象装载到list集合中
|
||||
chapterVos.add(chapterVo);
|
||||
}
|
||||
return chapterVos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChapter(String courseId, List<ChapterVo> chapterVos) {
|
||||
for (ChapterVo chapterVo : chapterVos) {
|
||||
EduChapter chapter = new EduChapter();
|
||||
chapter.setCourseId(courseId);
|
||||
chapter.setTitle(chapterVo.getTitle());
|
||||
System.out.println(chapter);
|
||||
int i = baseMapper.insert(chapter);
|
||||
if (i == 0) {
|
||||
throw new MyException(20001, "添加章节失败");
|
||||
} else {
|
||||
for (VideoVo v : chapterVo.getChildren()) {
|
||||
EduVideo eduVideo = new EduVideo();
|
||||
eduVideo.setChapterId(chapter.getId());
|
||||
eduVideo.setCourseId(courseId);
|
||||
eduVideo.setTitle(v.getTitle());
|
||||
boolean save = eduVideoService.save(eduVideo);
|
||||
if (!save) {
|
||||
throw new MyException(20001, "添加失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteChapterAndVideoByChapterId(String chapterId) {
|
||||
|
||||
//删除小节
|
||||
QueryWrapper<EduVideo> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("chapter_id", chapterId);
|
||||
//获取小节并根据视频id删除视频
|
||||
List<EduVideo> list = eduVideoService.list(wrapper);
|
||||
List<String> videoIds = new ArrayList<>();
|
||||
for (EduVideo v : list) {
|
||||
videoIds.add(v.getVideoSourceId());
|
||||
}
|
||||
R r = vodClient.deleteByIds(videoIds);
|
||||
if (r.getCode() == 20001) {
|
||||
throw new MyException(20001, "删除失败");
|
||||
}
|
||||
//删除小节
|
||||
eduVideoService.remove(wrapper);
|
||||
//删除章节
|
||||
baseMapper.deleteById(chapterId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteVideoById(String videoId) {
|
||||
EduVideo video = eduVideoService.getById(videoId);
|
||||
String videoSourceId = video.getVideoSourceId();
|
||||
//删除视频
|
||||
R r = vodClient.deleteById(videoSourceId);
|
||||
if (r.getCode() == 20001) {
|
||||
throw new MyException(20001, "删除失败");
|
||||
} else {
|
||||
if (!eduVideoService.removeById(videoId)) {
|
||||
throw new MyException(20001, "删除失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.llw.eduservice.service.impl;
|
||||
|
||||
import com.llw.eduservice.domain.EduComment;
|
||||
import com.llw.eduservice.mapper.EduCommentMapper;
|
||||
import com.llw.eduservice.service.EduCommentService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 评论 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-14
|
||||
*/
|
||||
@Service
|
||||
public class EduCommentServiceImpl extends ServiceImpl<EduCommentMapper, EduComment> implements EduCommentService {
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.llw.eduservice.service.impl;
|
||||
|
||||
import com.llw.eduservice.domain.EduCourseCollect;
|
||||
import com.llw.eduservice.mapper.EduCourseCollectMapper;
|
||||
import com.llw.eduservice.service.EduCourseCollectService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程收藏 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-14
|
||||
*/
|
||||
@Service
|
||||
public class EduCourseCollectServiceImpl extends ServiceImpl<EduCourseCollectMapper, EduCourseCollect> implements EduCourseCollectService {
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.llw.eduservice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.llw.eduservice.domain.EduCourseDescription;
|
||||
import com.llw.eduservice.mapper.EduCourseDescriptionMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程简介 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@Service
|
||||
public class EduCourseDescriptionServiceImpl extends ServiceImpl<EduCourseDescriptionMapper, EduCourseDescription> implements IService<EduCourseDescription> {
|
||||
|
||||
}
|
@ -0,0 +1,159 @@
|
||||
package com.llw.eduservice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.llw.commonutils.vo.R;
|
||||
import com.llw.eduservice.domain.EduCourse;
|
||||
import com.llw.eduservice.domain.EduCourseDescription;
|
||||
import com.llw.eduservice.domain.query.HomeCourseQuery;
|
||||
import com.llw.eduservice.domain.vo.CourseInfo;
|
||||
import com.llw.eduservice.domain.vo.CourseInfoForm;
|
||||
import com.llw.eduservice.domain.vo.CourseQuery;
|
||||
import com.llw.eduservice.mapper.EduChapterMapper;
|
||||
import com.llw.eduservice.mapper.EduCourseDescriptionMapper;
|
||||
import com.llw.eduservice.mapper.EduCourseMapper;
|
||||
import com.llw.eduservice.mapper.EduVideoMapper;
|
||||
import com.llw.eduservice.service.EduCourseService;
|
||||
import com.llw.servicebase.exception.MyException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@Service
|
||||
public class EduCourseServiceImpl extends ServiceImpl<EduCourseMapper, EduCourse> implements EduCourseService {
|
||||
@Autowired
|
||||
private EduCourseMapper eduCourseMapper;
|
||||
@Autowired
|
||||
private EduCourseDescriptionMapper descriptionMapper;
|
||||
@Autowired
|
||||
private EduVideoMapper videoMapper;
|
||||
@Autowired
|
||||
private EduChapterMapper chapterMapper;
|
||||
|
||||
@Override
|
||||
public String saveCourseInfo(CourseInfoForm courseInfo) {
|
||||
EduCourse eduCourse = new EduCourse();
|
||||
BeanUtils.copyProperties(courseInfo,eduCourse);
|
||||
int result = baseMapper.insert(eduCourse);
|
||||
if(result==0){
|
||||
throw new MyException(20001,"添加失败");
|
||||
}
|
||||
EduCourseDescription description = new EduCourseDescription();
|
||||
description.setId(eduCourse.getId());
|
||||
description.setDescription(courseInfo.getDescription());
|
||||
descriptionMapper.insert(description);
|
||||
return description.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CourseInfoForm getCourseVo(String courseId) {
|
||||
EduCourse eduCourse = baseMapper.selectById(courseId);
|
||||
CourseInfoForm courseInfoForm = new CourseInfoForm();
|
||||
BeanUtils.copyProperties(eduCourse,courseInfoForm);
|
||||
EduCourseDescription description = descriptionMapper.selectById(courseId);
|
||||
courseInfoForm.setDescription(description.getDescription());
|
||||
return courseInfoForm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCourseAndDes(String courseId, CourseInfoForm courseInfoForm) {
|
||||
EduCourse eduCourse = new EduCourse();
|
||||
EduCourseDescription description = new EduCourseDescription();
|
||||
BeanUtils.copyProperties(courseInfoForm,eduCourse);
|
||||
eduCourse.setId(courseId);
|
||||
description.setId(courseId);
|
||||
description.setDescription(courseInfoForm.getDescription());
|
||||
baseMapper.updateById(eduCourse);
|
||||
descriptionMapper.updateById(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CourseInfo getCourseInfo(String courseId) {
|
||||
return eduCourseMapper.getCourseInfo(courseId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R pageList(Long page, Long limit, CourseQuery courseQuery) {
|
||||
Page<EduCourse> pageCourse = new Page<>(page,limit);
|
||||
QueryWrapper<EduCourse> wrapper = new QueryWrapper<>();
|
||||
if(courseQuery!=null){
|
||||
String subjectId = courseQuery.getSubjectId();
|
||||
String title = courseQuery.getTitle();
|
||||
String subjectParentId = courseQuery.getSubjectParentId();
|
||||
String teacherId = courseQuery.getTeacherId();
|
||||
if (!StringUtils.isEmpty(title)) {
|
||||
wrapper.ge("title", subjectId);
|
||||
}
|
||||
if (!StringUtils.isEmpty(subjectId)) {
|
||||
wrapper.ge("subject_id", subjectId);
|
||||
}
|
||||
if (!StringUtils.isEmpty(subjectParentId)) {
|
||||
wrapper.ge("subject_parent_id", subjectId);
|
||||
}
|
||||
if (!StringUtils.isEmpty(teacherId)) {
|
||||
wrapper.ge("teacher_id", subjectId);
|
||||
}
|
||||
}
|
||||
IPage<EduCourse> eduCourseIPage = baseMapper.selectPage(pageCourse, wrapper);
|
||||
long total = eduCourseIPage.getTotal();
|
||||
List<EduCourse> eduCourses = eduCourseIPage.getRecords();
|
||||
return total>0 ? R.ok().data("total",total).data("items",eduCourses) : R.error();
|
||||
}
|
||||
@Override
|
||||
public R homePageList(Long page, Long limit, HomeCourseQuery homeCourseQuery) {
|
||||
Page<EduCourse> pageCourse = new Page<>(page,limit);
|
||||
QueryWrapper<EduCourse> wrapper = new QueryWrapper<>();
|
||||
if(homeCourseQuery!=null){
|
||||
String subjectId = homeCourseQuery.getSubjectId();
|
||||
int price = homeCourseQuery.getPrice();
|
||||
boolean gmtCreate = homeCourseQuery.isGmtCreate();
|
||||
boolean viewCount = homeCourseQuery.isViewCount();
|
||||
if (!StringUtils.isEmpty(subjectId)) {
|
||||
wrapper.ge("subject_id", subjectId);
|
||||
}
|
||||
if(price>0){
|
||||
wrapper.orderByDesc("price");
|
||||
}
|
||||
if(price<0){
|
||||
wrapper.orderByAsc("price");
|
||||
}
|
||||
if(viewCount){
|
||||
wrapper.orderByDesc("view_count");
|
||||
}
|
||||
if(gmtCreate){
|
||||
wrapper.orderByDesc("gmt_create");
|
||||
}
|
||||
}
|
||||
IPage<EduCourse> eduCourseIPage = baseMapper.selectPage(pageCourse, wrapper);
|
||||
long total = eduCourseIPage.getTotal();
|
||||
List<EduCourse> eduCourses = eduCourseIPage.getRecords();
|
||||
return total>0 ? R.ok().data("total",total).data("items",eduCourses) : R.error();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String id) {
|
||||
int i = baseMapper.deleteById(id);
|
||||
QueryWrapper wrapper = new QueryWrapper();
|
||||
wrapper.eq("course_id",id);
|
||||
if(i!=0){
|
||||
chapterMapper.delete(wrapper);
|
||||
videoMapper.delete(wrapper);
|
||||
}else{
|
||||
throw new MyException(20001,"删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.llw.eduservice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.llw.commonutils.vo.R;
|
||||
import com.llw.eduservice.domain.EduTeacher;
|
||||
import com.llw.eduservice.mapper.EduTeacherMapper;
|
||||
import com.llw.eduservice.query.TeacherQuery;
|
||||
import com.llw.eduservice.service.EduTeacherService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 讲师 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-11-25
|
||||
*/
|
||||
@Service
|
||||
public class EduTeacherServiceImpl extends ServiceImpl<EduTeacherMapper, EduTeacher> implements EduTeacherService {
|
||||
|
||||
@Override
|
||||
public R pageList(long page, long limit, TeacherQuery teacherQuery) {
|
||||
Page<EduTeacher> pageTeacher = new Page<>(page,limit);
|
||||
QueryWrapper<EduTeacher> queryWrapper = new QueryWrapper<>();
|
||||
if(teacherQuery!=null){
|
||||
String name = teacherQuery.getName();
|
||||
Integer level = teacherQuery.getLevel();
|
||||
String begin = teacherQuery.getBegin();
|
||||
String end = teacherQuery.getEnd();
|
||||
if(!StringUtils.isEmpty(name)){
|
||||
queryWrapper.like("name",name);
|
||||
}
|
||||
if(level!=null){
|
||||
queryWrapper.eq("level",level);
|
||||
}
|
||||
if(!StringUtils.isEmpty(end)){
|
||||
queryWrapper.le("gmt_create",end);
|
||||
}
|
||||
if(!StringUtils.isEmpty(begin)){
|
||||
queryWrapper.ge("gmt_create",begin);
|
||||
}
|
||||
queryWrapper.orderByDesc("gmt_create");
|
||||
}
|
||||
this.page(pageTeacher, queryWrapper);
|
||||
long total = pageTeacher.getTotal();
|
||||
List<EduTeacher> records = pageTeacher.getRecords();
|
||||
return total>0 ? R.ok().data("total",total).data("items",records) : R.error();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.llw.eduservice.service.impl;
|
||||
|
||||
import com.llw.eduservice.domain.EduVideo;
|
||||
import com.llw.eduservice.mapper.EduVideoMapper;
|
||||
import com.llw.eduservice.service.EduVideoService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程视频 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 李亮文
|
||||
* @since 2020-12-06
|
||||
*/
|
||||
@Service
|
||||
public class EduVideoServiceImpl extends ServiceImpl<EduVideoMapper, EduVideo> implements EduVideoService {
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.llw.test;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.PackageConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 2018/12/13
|
||||
*/
|
||||
public class CodeGenerator {
|
||||
|
||||
@Test
|
||||
public void run() {
|
||||
|
||||
// 1、创建代码生成器
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
// 2、全局配置
|
||||
GlobalConfig gc = new GlobalConfig();
|
||||
// String projectPath = System.getProperty("user.dir");
|
||||
gc.setOutputDir("E:\\Java\\blue_stare\\service\\service_edu" + "/src/main/java");
|
||||
gc.setAuthor("李亮文");
|
||||
gc.setOpen(false); //生成后是否打开资源管理器
|
||||
gc.setFileOverride(false); //重新生成时文件是否覆盖
|
||||
gc.setServiceName("%sService"); //去掉Service接口的首字母I
|
||||
gc.setIdType(IdType.ID_WORKER_STR); //主键策略
|
||||
gc.setDateType(DateType.ONLY_DATE);//定义生成的实体类中日期类型
|
||||
gc.setSwagger2(true);//开启Swagger2模式
|
||||
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
// 3、数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setUrl("jdbc:mysql://localhost:3306/blue_star?serverTimezone=GMT%2B8");
|
||||
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
|
||||
dsc.setUsername("root");
|
||||
dsc.setPassword("mysqladmin");
|
||||
dsc.setDbType(DbType.MYSQL);
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
// 4、包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
pc.setModuleName("eduservice"); //模块名
|
||||
pc.setParent("com.llw");
|
||||
pc.setController("controller");
|
||||
pc.setEntity("domain");
|
||||
pc.setService("service");
|
||||
pc.setMapper("mapper");
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
// 5、策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setInclude("edu_course_collect","edu_comment");
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
|
||||
strategy.setTablePrefix(pc.getModuleName() + "_"); //生成实体时去掉表前缀
|
||||
|
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);//数据库表字段映射到实体的命名策略
|
||||
strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作
|
||||
|
||||
strategy.setRestControllerStyle(true); //restful api风格控制器
|
||||
strategy.setControllerMappingHyphenStyle(true); //url中驼峰转连字符
|
||||
|
||||
mpg.setStrategy(strategy);
|
||||
|
||||
|
||||
// 6、执行
|
||||
mpg.execute();
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: Hash
|
||||
* Author: Caesar
|
||||
* Date: 2020-12-05 16:43
|
||||
* Description:
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈〉
|
||||
*
|
||||
* @author Caesar
|
||||
* @create 2020-12-05
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Hash {
|
||||
@Test
|
||||
public void RSHash() {
|
||||
String str = "111";
|
||||
int b = 378551;
|
||||
int a = 63689;
|
||||
long hash = 0;
|
||||
|
||||
for(int i = 0; i < str.length(); i++)
|
||||
{
|
||||
hash = hash * a + str.charAt(i);
|
||||
a = a * b;
|
||||
}
|
||||
|
||||
System.out.println(hash);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>service</artifactId>
|
||||
<groupId>com.llw</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>service_msm</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright (C), 2015-2020, XXX有限公司
|
||||
* FileName: MsmApplication
|
||||
* Author: 李亮文
|
||||
* Date: 2020-12-22 12:55
|
||||
* Description: 短信服务启动类
|
||||
* History:
|
||||
* <author> <time> <version> <desc>
|
||||
* 作者姓名 修改时间 版本号 描述
|
||||
*/
|
||||
package com.llw.msm;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 〈一句话功能简述〉<br>
|
||||
* 〈短信服务启动类〉
|
||||
*
|
||||
* @author 李亮文
|
||||
* @create 2020-12-22
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
@ComponentScan({"com.llw"})
|
||||
public class MsmApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MsmApplication.class,args);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue