Commit ff085fbe by 石头

提交admin

1 parent ec59bca0
<?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>cihai</artifactId>
<groupId>com.dookay</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cihai-app</artifactId>
<packaging>war</packaging>
<properties>
<maven.test.skip>true</maven.test.skip>
<jetty.scope>compile</jetty.scope>
</properties>
<dependencies>
<dependency>
<groupId>com.dookay</groupId>
<artifactId>coral-common-web</artifactId>
</dependency>
<dependency>
<groupId>com.dookay</groupId>
<artifactId>cihai-core</artifactId>
</dependency>
<!--开发工具-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!--表现层-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<scope>${jetty.scope}</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<scope>${jetty.scope}</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<scope>${jetty.scope}</scope>
</dependency>
<!--表现层-->
<!--工具-->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<!--接口文档-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
<!--接口文档-->
</dependencies>
</project>
package com.dookay.cihai.admin;
import com.dookay.cihai.core.CiHaiCoreApplication;
import com.dookay.coral.common.core.CoralCommonCoreMarker;
import com.dookay.coral.common.web.CoralCommonWebMarker;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
/**
* 项目运行入口
*
* @author houkun
*/
@SpringBootApplication(
// 加载不同模块的配置与待注入的Bean
scanBasePackageClasses = {
CoralCommonCoreMarker.class,
CoralCommonWebMarker.class,
CihaiAdminApplication.class,
CiHaiCoreApplication.class
})
@ServletComponentScan(basePackageClasses = {
CoralCommonWebMarker.class,
CihaiAdminApplication.class,
CiHaiCoreApplication.class
})
@MapperScan(basePackageClasses = CiHaiCoreApplication.class)
@EnableCaching
public class CihaiAdminApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(CihaiAdminApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(CihaiAdminApplication.class, args);
}
}
package com.dookay.cihai.admin.config;
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.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* 接口文档配置
*
* @author houkun
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket demoApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Coral Demo 示例接口文档")
.description("示例描述")
.version("0.1")
.build();
}
}
package com.dookay.cihai.admin.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
* Web config
*
* @author houkun
*/
@Configuration
public class WebAdminConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
/*****************************************
* *
* @dookay.com Internet make it happen *
* ----------- ----------------------- *
* dddd ddddd Internet make it happen *
* o o o Internet make it happen *
* k k k Internet make it happen *
* a a a Internet make it happen *
* yyyy yyyyy Internet make it happen *
* ----------- ----------------------- *
* NO BUG ENJOY LIFE *
* *
****************************************/
package com.dookay.cihai.admin.controller;
import com.dookay.cihai.admin.controller.form.ThemeForm;
import com.dookay.cihai.core.theme.domain.ThemeDomain;
import com.dookay.cihai.core.theme.query.ThemeQuery;
import com.dookay.cihai.core.theme.service.IThemeService;
import com.dookay.coral.common.core.persistence.pager.PageList;
import com.dookay.coral.common.web.constant.MediaTypes;
import com.dookay.coral.common.web.controller.BaseController;
import com.dookay.coral.common.web.response.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* @author 石磊
* @date 2017/12/6
*/
@RestController
@RequestMapping("/theme")
public class ThemeController extends BaseController {
@Autowired
private IThemeService themeService;
/**
* @author 石磊
* @date 2017/12/6
* @description 专题列表
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
public JsonResult list(ThemeQuery q) {
PageList<ThemeDomain> list = themeService.getPageList(q);
return successResult(list);
}
/**
* @author 石磊
* @date 2017/12/6
* @description 主题详情
*/
@RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
public JsonResult detail(@PathVariable Long id) {
ThemeDomain themeDomain = themeService.get(id);
return successResult(themeDomain);
}
/**
* @author 石磊
* @date 2017/12/6
* @description 创建主题
*/
@RequestMapping(value = "/create", method = RequestMethod.POST, produces = MediaTypes.JSON_UTF_8)
public JsonResult create(ThemeForm form) {
ThemeDomain themeDomain = form.toDomain();
themeService.create(themeDomain);
return successResult("success");
}
/**
* @author 石磊
* @date 2017/12/6
* @description 编辑主题
*/
@RequestMapping(value = "/edit", method = RequestMethod.POST, produces = MediaTypes.JSON_UTF_8)
public JsonResult edit(ThemeForm form) {
ThemeDomain themeDomain = form.toDomain();
themeService.update(themeDomain);
return successResult("success");
}
/**
* @author 石磊
* @date 2017/12/6
* @description 删除主题
*/
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST, produces = MediaTypes.JSON_UTF_8)
public JsonResult delete(@PathVariable Long id) {
themeService.delete(id);
return successResult("success");
}
}
/*****************************************
* *
* @dookay.com Internet make it happen *
* ----------- ----------------------- *
* dddd ddddd Internet make it happen *
* o o o Internet make it happen *
* k k k Internet make it happen *
* a a a Internet make it happen *
* yyyy yyyyy Internet make it happen *
* ----------- ----------------------- *
* NO BUG ENJOY LIFE *
* *
****************************************/
package com.dookay.cihai.admin.controller;
import com.dookay.cihai.admin.controller.form.WordForm;
import com.dookay.cihai.core.word.domain.WordDomain;
import com.dookay.cihai.core.word.query.WordQuery;
import com.dookay.cihai.core.word.service.IWordService;
import com.dookay.coral.common.core.persistence.pager.PageList;
import com.dookay.coral.common.web.constant.MediaTypes;
import com.dookay.coral.common.web.controller.BaseController;
import com.dookay.coral.common.web.response.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* @author 石磊
* @date 2017/12/6
*/
@RequestMapping("/word")
@RestController
public class WordController extends BaseController {
@Autowired
private IWordService wordService;
/**
* @author 石磊
* @date 2017/12/6
* @description 词条列表
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
public JsonResult list(WordQuery query) {
PageList<WordDomain> wordList = wordService.getPageList(query);
return successResult(wordList);
}
/**
* @author 石磊
* @date 2017/12/6
* @description 词条详情
*/
@RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
public JsonResult detail(@PathVariable Long id) {
WordDomain wordDomain = wordService.get(id);
return successResult(wordDomain);
}
/**
* @author 石磊
* @date 2017/12/6
* @description 创建词条
*/
@RequestMapping(value = "/create", method = RequestMethod.POST, produces = MediaTypes.JSON_UTF_8)
public JsonResult create(WordForm form) {
WordDomain wordDomain = form.toDomain();
wordService.create(wordDomain);
return successResult("success");
}
/**
* @author 石磊
* @date 2017/12/6
* @description 编辑词条
*/
@RequestMapping(value = "/edit", method = RequestMethod.POST, produces = MediaTypes.JSON_UTF_8)
public JsonResult edit(WordForm form) {
WordDomain wordDomain = form.toDomain();
wordService.update(wordDomain);
return successResult("success");
}
/**
* @author 石磊
* @date 2017/12/6
* @description 删除词条
*/
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST, produces = MediaTypes.JSON_UTF_8)
public JsonResult delete(@PathVariable Long id) {
wordService.delete(id);
return successResult("success");
}
}
/*****************************************
* *
* @dookay.com Internet make it happen *
* ----------- ----------------------- *
* dddd ddddd Internet make it happen *
* o o o Internet make it happen *
* k k k Internet make it happen *
* a a a Internet make it happen *
* yyyy yyyyy Internet make it happen *
* ----------- ----------------------- *
* NO BUG ENJOY LIFE *
* *
****************************************/
package com.dookay.cihai.admin.controller.form;
import com.dookay.cihai.core.theme.domain.ThemeDomain;
import com.dookay.coral.common.core.utils.bean.BeanMapper;
import lombok.Data;
import java.util.Date;
/**
* @author 石磊
* @date 2017/12/6
*/
@Data
public class ThemeForm {
private Long id;
/**
*
*/
private String title;
/**
*
*/
private String introduce;
/**
*
*/
private String basicInfo;
private Date updateTime = new Date();
public ThemeDomain toDomain() {
return BeanMapper.map(this, ThemeDomain.class);
}
}
/*****************************************
* *
* @dookay.com Internet make it happen *
* ----------- ----------------------- *
* dddd ddddd Internet make it happen *
* o o o Internet make it happen *
* k k k Internet make it happen *
* a a a Internet make it happen *
* yyyy yyyyy Internet make it happen *
* ----------- ----------------------- *
* NO BUG ENJOY LIFE *
* *
****************************************/
package com.dookay.cihai.admin.controller.form;
import com.dookay.cihai.core.word.domain.WordDomain;
import com.dookay.coral.common.core.utils.bean.BeanMapper;
import lombok.Data;
import java.util.Date;
/**
* @author 石磊
* @date 2017/12/6
*/
@Data
public class WordForm {
private Long id;
/**
*
*/
private String word;
/**
*
*/
private String body;
/**
*
*/
private String baikePoster;
/**
*
*/
private String baikeVoice;
/**
*
*/
private String baikeDescription;
/**
*
*/
private String baikeParaphrase;
/**
*
*/
private String baikePhotos;
/**
*
*/
private String baikeVideo;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime=new Date();
/**
* 拼音
*/
private String wordSpell;
public WordDomain toDomain() {
return BeanMapper.map(this, WordDomain.class);
}
}
# 解决 springboot-devtool 影响 tk.mybatis.mapper 插件报错问题
# 详见: https://github.com/abel533/MyBatis-Spring-Boot/issues/5
restart.include.mapper=/mapper-[\\w-\\.]+jar
restart.include.pagehelper=/pagehelper-[\\w-\\.]+jar
restart.include.coralcommon=/coral-common-[\\w-\\.]+jar
restart.include.coraldemocore=/cihai-core[\\w-\\.]+jar
\ No newline at end of file
debug=false
# 数据库连接
spring.datasource.url=jdbc:mysql://192.168.2.24:3306/cihai
spring.datasource.username=root
# 加密后的密码
spring.datasource.password=AmwpshLB35Fgazrs4rCfGlwNBZOTD34ezY/zS751V+7iSJHjr3tDNkpOfnW/y0fjFcMTNX0ycMt3KIUnDi8JYg==
# 加密时的公钥
public-key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKgof5ExfKmEZEjq+GuqEoHA8tkIftarLRzUDAxdQzJQtF57DF63gPJJkIZLcKa2t8jt5JC2SRdxERg1A/kx0BMCAwEAAQ==
# 日志
logging.level.root=info
logging.level.com.dookay.core=trace
# redis
spring.redis.host=192.168.2.27
spring.redis.password=lyd123456
# 文件存储
coral.web.resource.mapping.uploads-inner=/uploads/*
coral.web.resource.mapping.uploads-mapping=/data/www/uploads/cihai
# 数据库连接
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
# 加密后的密码
spring.datasource.password=UvoEsj8TZ9a11DQRR42EGuoIRjeuqSagmUzCdUeDnw9PJ9hum0Lx/MTPrpIR7isrPdA8lMpaY77eW4g3f1tCQQ==
# 加密时的公钥
public-key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJFbtR5GoNcW9j8b4RhZQ1CC1xNBx8Sqphxc8/6vNWYdd7d84AUfSAzFXCzGvuvJ0URNAg9IykPDexY/mHP8dA0CAwEAAQ==
# 日志
logging.level.root=error
logging.level.com.dookay.coral.common.core=info
logging.level.com.dookay.coral.common.web=info
logging.level.com.dookay.front=info
logging.level.com.dookay.core=info
logging.file=/data/www/log/cihai.log
# redis
spring.redis.host=127.0.0.1
# 上传文件路径映射
coral.web.resource.mapping.uploads-inner=/uploads/**
coral.web.resource.mapping.uploads-mapping=file:/data/www/uploads/demo/
# 打开 gzip
server.compression.enabled=true
# 数据库连接
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
# 加密后的密码
spring.datasource.password=UvoEsj8TZ9a11DQRR42EGuoIRjeuqSagmUzCdUeDnw9PJ9hum0Lx/MTPrpIR7isrPdA8lMpaY77eW4g3f1tCQQ==
# 加密时的公钥
public-key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJFbtR5GoNcW9j8b4RhZQ1CC1xNBx8Sqphxc8/6vNWYdd7d84AUfSAzFXCzGvuvJ0URNAg9IykPDexY/mHP8dA0CAwEAAQ==
# 日志
logging.level.root=warn
logging.level.com.dookay.coral.common.core=debug
logging.level.com.dookay.coral.common.web=debug
logging.level.com.dookay.front=debug
logging.level.com.dookay.core=debug
logging.file=/data/www/log/cihai.log
# redis
spring.redis.host=127.0.0.1
# 上传文件路径映射
coral.web.resource.mapping.uploads-inner=/uploads/**
coral.web.resource.mapping.uploads-mapping=file:/data/www/uploads/demo/
# 打开 gzip
server.compression.enabled=true
# 通用配置
spring.profiles.active=dev
# druid性能相关配置
spring.datasource.druid.initial-size=5
spring.datasource.druid.max-active=50
spring.datasource.druid.min-idle=5
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.test-on-return=false
spring.datasource.druid.test-while-idle=true
spring.datasource.druid.validation-query=select 1
spring.datasource.druid.max-wait=5000
spring.datasource.druid.time-between-eviction-runs-millis=600000
spring.datasource.druid.min-evictable-idle-time-millis=1800000
# druid解密配置
spring.datasource.druid.connection-properties=config.decrypt=true;config.decrypt.key=${public-key}
spring.datasource.druid.filter.config.enabled=true
# 关闭druid监控
spring.datasource.druid.filter.stat.enabled=false
# mybatis插件配置
# 设置扫描 mapper xml路径
mapper.mappers=com.dookay.coral.common.core.persistence.Mapper
mybatis.mapper-locations=classpath*:mapper/*.xml
# jsp页面配置
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
# 错误页面
coral.web.view.error.not-found=404
coral.web.view.error.bad-request=400
coral.web.view.error.internal-error=500
coral.web.view.error.service=service
coral.web.view.error.other=other
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!