初次提交
This commit is contained in:
parent
ec939cbbd1
commit
175fe99f7c
|
@ -0,0 +1,120 @@
|
|||
<?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>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.lingu.suElec</groupId>
|
||||
<artifactId>study</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>study</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<!--<swagger-ui.version>2.9.2</swagger-ui.version>-->
|
||||
<!--<springfox.version>2.9.2</springfox.version>-->
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.35</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--Mybatis部分-->
|
||||
<!--mysql连接-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<version>8.0.18</version>
|
||||
</dependency>
|
||||
<!--mybatis启动器-->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--添加lombok插件-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!--swagger文档-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>io.springfox</groupId>-->
|
||||
<!--<artifactId>springfox-swagger2</artifactId>-->
|
||||
<!--<version>${springfox.version}</version>-->
|
||||
<!--</dependency>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>io.springfox</groupId>-->
|
||||
<!--<artifactId>springfox-swagger-ui</artifactId>-->
|
||||
<!--<version>${springfox.version}</version>-->
|
||||
<!--</dependency>-->
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,14 @@
|
|||
package com.lingu.suelec.study;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
//@EnableSwagger2
|
||||
public class StudyApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(StudyApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
//package com.lingu.suelec.study.config;
|
||||
//
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import springfox.documentation.builders.ApiInfoBuilder;
|
||||
//import springfox.documentation.builders.ParameterBuilder;
|
||||
//import springfox.documentation.builders.PathSelectors;
|
||||
//import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
//import springfox.documentation.schema.ModelRef;
|
||||
//import springfox.documentation.service.ApiInfo;
|
||||
//import springfox.documentation.service.Parameter;
|
||||
//import springfox.documentation.spi.DocumentationType;
|
||||
//import springfox.documentation.spring.web.plugins.Docket;
|
||||
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@Configuration
|
||||
//@EnableSwagger2
|
||||
//public class SwaggerConfig {
|
||||
//
|
||||
// @Bean
|
||||
// public Docket createRestApi() {
|
||||
// return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
|
||||
// .apis(RequestHandlerSelectors.basePackage("com.lingu.suelec.study.controller")).paths(PathSelectors.any())
|
||||
// .build().globalOperationParameters(setHeaderToken());
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private ApiInfo apiInfo() {
|
||||
// return new ApiInfoBuilder().title("action-swagger").description("swagger实战").termsOfServiceUrl("")
|
||||
// .version("1.0").build();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @Description: 设置swagger文档中全局参数
|
||||
// * @param
|
||||
// * @Date: 2020/9/11 10:15
|
||||
// * @return: java.util.List<springfox.documentation.service.Parameter>
|
||||
// */
|
||||
//
|
||||
// private List<Parameter> setHeaderToken() {
|
||||
// List<Parameter> pars = new ArrayList<>();
|
||||
// ParameterBuilder userId = new ParameterBuilder();
|
||||
//// userId.name("token").description("用户TOKEN").modelRef(new ModelRef("string")).parameterType("header")
|
||||
//// .required(true).build();
|
||||
// pars.add(userId.build());
|
||||
// return pars;
|
||||
// }
|
||||
//}
|
||||
//
|
|
@ -0,0 +1,20 @@
|
|||
//package com.lingu.suelec.study.config;
|
||||
//
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
//@Configuration
|
||||
//@EnableWebMvc
|
||||
//public class WebMvcConfig implements WebMvcConfigurer {
|
||||
// @Override
|
||||
// public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
// //兼容swagger老版本v1,v2
|
||||
// registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");
|
||||
// registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
// registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
// registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
|
||||
// registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
// registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,43 @@
|
|||
package com.lingu.suelec.study.controller;
|
||||
|
||||
import com.lingu.suelec.study.service.TrainService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping
|
||||
|
||||
//@Api(value = "培训班接口")
|
||||
public class TrainController {
|
||||
@Resource
|
||||
TrainService trainService;
|
||||
|
||||
@RequestMapping("test")
|
||||
public String test(){
|
||||
return "11";
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的收藏-培训班
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
||||
//@ApiOperation("培训班查询")
|
||||
@RequestMapping("selectTrainInfo")
|
||||
public Object selectTrainInfo(@RequestParam String id){
|
||||
return trainService.selectTrainInfo(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//@ApiOperation("培训班查询")
|
||||
@RequestMapping("selectTtrainClassList")
|
||||
public Object selectTtrainClassList(String id){
|
||||
return trainService.selectTtrainClassList(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.lingu.suelec.study.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@Data
|
||||
public class TrainInfo {
|
||||
private String id;
|
||||
private String title;
|
||||
private String content;
|
||||
private String code;
|
||||
private String offerType;
|
||||
private String url;
|
||||
private String organizerName;
|
||||
private Date beginDate;
|
||||
private Date endDate;
|
||||
private String sortTitle;
|
||||
private Integer signedCount;
|
||||
private Integer learnedCount;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.lingu.suelec.study.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
@Data
|
||||
public class TrainingClass {
|
||||
private int id;
|
||||
private BigInteger userId;
|
||||
private int classId;
|
||||
private String type;
|
||||
private int seqNo;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TrainingClass{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", classId=" + classId +
|
||||
", type='" + type + '\'' +
|
||||
", seqNo=" + seqNo +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.lingu.suelec.study.mapper;
|
||||
|
||||
import com.lingu.suelec.study.domain.TrainInfo;
|
||||
import com.lingu.suelec.study.domain.TrainingClass;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface TrainMapper {
|
||||
|
||||
TrainInfo selectTrainInfo(String userId);
|
||||
List<TrainInfo> selectTtrainClassList();
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.lingu.suelec.study.service;
|
||||
|
||||
import com.lingu.suelec.study.domain.TrainInfo;
|
||||
import com.lingu.suelec.study.domain.TrainingClass;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface TrainService {
|
||||
TrainInfo selectTrainInfo(String id);
|
||||
List<TrainInfo> selectTtrainClassList(String id);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.lingu.suelec.study.service.impl;
|
||||
|
||||
import com.lingu.suelec.study.domain.TrainInfo;
|
||||
import com.lingu.suelec.study.domain.TrainingClass;
|
||||
import com.lingu.suelec.study.mapper.TrainMapper;
|
||||
import com.lingu.suelec.study.service.TrainService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class TrainServiceImpl implements TrainService{
|
||||
|
||||
@Resource
|
||||
TrainMapper trainMapper;
|
||||
@Override
|
||||
public TrainInfo selectTrainInfo(String id) {
|
||||
TrainInfo trainingClass = trainMapper.selectTrainInfo(id);
|
||||
return trainingClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TrainInfo> selectTtrainClassList(String id) {
|
||||
List<TrainInfo> list = trainMapper.selectTtrainClassList();
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.lingu.suelec.study.test;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/test")
|
||||
public class Test {
|
||||
|
||||
@GetMapping("/1")
|
||||
public void fileDownload(@RequestParam String xx)
|
||||
{
|
||||
System.out.print("xxx="+xx);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
spring:
|
||||
datasource:
|
||||
#url: jdbc:mysql://47.99.240.224:3306/power_grid?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
url: jdbc:mysql://172.16.1.254:3306/training_class_bak?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: Unity3du#d112233
|
||||
|
||||
# PageHelper分页
|
||||
pagehelper:
|
||||
helperDialect: mysql
|
||||
supportMethodsArguments: true
|
||||
params: count=countSql
|
||||
|
||||
# MyBatis配置
|
||||
mybatis:
|
||||
typeAliasesPackage: com.lingu.suelec.study.**.domain
|
||||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||
configLocation: classpath:mapper/mybatis-config.xml
|
|
@ -0,0 +1,30 @@
|
|||
spring:
|
||||
datasource:
|
||||
#url: jdbc:mysql://47.99.240.224:3306/power_grid?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
url: jdbc:mysql://172.16.1.254:3306/training_class_bak?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: Unity3du#d112233
|
||||
|
||||
|
||||
# PageHelper分页
|
||||
pagehelper:
|
||||
helperDialect: mysql
|
||||
supportMethodsArguments: true
|
||||
params: count=countSql
|
||||
|
||||
|
||||
|
||||
# MyBatis配置
|
||||
mybatis:
|
||||
typeAliasesPackage: com.linggu.suelec.study.**.domain
|
||||
mapperLocations: classpath*:mybatis/**/*Mapper.xml
|
||||
configLocation: classpath:mybatis/mybatis-config.xml
|
||||
|
||||
|
||||
# 系统日志
|
||||
#logging:
|
||||
# level:
|
||||
# root: info
|
||||
# com.blog: debug
|
||||
# file: log/blog-dev.log
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
|
||||
server:
|
||||
port: 8080
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<!-- 全局参数 -->
|
||||
<settings>
|
||||
<!-- 使全局的映射器启用或禁用缓存 -->
|
||||
<setting name="cacheEnabled" value="true" />
|
||||
<!-- 允许JDBC 支持自动生成主键 -->
|
||||
<setting name="useGeneratedKeys" value="true" />
|
||||
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
|
||||
<setting name="defaultExecutorType" value="SIMPLE" />
|
||||
<!-- 指定 MyBatis 所用日志的具体实现 -->
|
||||
<setting name="logImpl" value="SLF4J" />
|
||||
<!-- 使用驼峰命名法转换字段 -->
|
||||
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||
</settings>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,78 @@
|
|||
<?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.lingu.suelec.study.mapper.TrainMapper">
|
||||
|
||||
<resultMap type="com.lingu.suelec.study.domain.TrainInfo" id="TrainInfo">
|
||||
<id property="id" column="id"/>
|
||||
<result property="title" column="title" />
|
||||
<result property="content" column="content"/>
|
||||
<result property="code" column="CODE"/>
|
||||
<result property="offerType" column="offer_type"/>
|
||||
<result property="url" column="cover_img_url"/>
|
||||
<result property="organizerName" column="organizer_name"/>
|
||||
<result property="beginDate" column="begin_date"/>
|
||||
<result property="endDate" column="end_date"/>
|
||||
<result property="sortTitle" column="sort_title"/>
|
||||
<result property="signedCount" column="signed_count"/>
|
||||
<result property="learnedCount" column="learned_count"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectTrainInfo" resultType="list" parameterType="java.lang.String">
|
||||
SELECT
|
||||
c.id,
|
||||
c.title,
|
||||
c.content,
|
||||
c.CODE,
|
||||
c.offer_type,
|
||||
c.cover_img_url,
|
||||
c.organizer_name,
|
||||
c.begin_date,
|
||||
c.end_date,
|
||||
s.sort_title,
|
||||
c.signed_count,
|
||||
c.learned_count
|
||||
FROM
|
||||
t_training_class_collection co
|
||||
LEFT JOIN t_training_class c ON c.id = co.class_id
|
||||
LEFT JOIN t_class_sort_rela r ON r.class_id = c.id
|
||||
LEFT JOIN t_trianing_class_sort s ON s.id = r.class_sort_id
|
||||
WHERE co.user_id=#{userId} AND co.`status` = 1
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectTtrainClassList" resultType="TrainInfo">
|
||||
SELECT
|
||||
a.id,
|
||||
a.CODE,
|
||||
a.offer_type,
|
||||
a.title,
|
||||
a.short_title,
|
||||
a.training_target,
|
||||
a.content,
|
||||
a.cover_img_url,
|
||||
a.organizer_name,
|
||||
a.begin_date,
|
||||
a.end_date,
|
||||
a.signed_count,
|
||||
a.learned_count,
|
||||
d.sort_title
|
||||
FROM
|
||||
t_training_class a
|
||||
LEFT JOIN t_user_sign_training_class b ON a.id = b.class_id
|
||||
AND b.STATUS = 1
|
||||
LEFT JOIN t_class_sort_rela c ON a.id = c.class_id
|
||||
LEFT JOIN t_trianing_class_sort d ON c.class_sort_id = d.id
|
||||
AND d.`status` = 1
|
||||
</select>
|
||||
|
||||
<!--<select id="selectTrainInfo" resultMap="TrainInfo" parameterType="java.lang.String">-->
|
||||
|
||||
|
||||
<!--</select>-->
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,12 @@
|
|||
package com.lingu.suelec.study;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class StudyApplicationTests {
|
||||
|
||||
// @Test
|
||||
// void contextLoads() {
|
||||
// }
|
||||
|
||||
}
|
Loading…
Reference in New Issue