chendi 8 gadi atpakaļ
vecāks
revīzija
159434faf2

+ 6 - 2
editor.iml

@ -49,8 +49,6 @@
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.6.5" level="project" />
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.6.5" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-web:4.2.4.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.2.4.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.2.4.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.2.4.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-expression:4.2.4.RELEASE" level="project" />
@ -96,5 +94,11 @@
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.4" level="project" />
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.6" level="project" />
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.3" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-security:1.3.2.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.2.4.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:4.0.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-core:4.0.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:4.0.3.RELEASE" level="project" />
  </component>
</module>

+ 5 - 0
pom.xml

@ -117,6 +117,11 @@
			<artifactId>httpmime</artifactId>
			<version>4.5.3</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-security</artifactId>
		</dependency>
	</dependencies>
	
	<build>

+ 53 - 0
src/main/java/com/yihu/editor/config/WebSecurityConfig.java

@ -0,0 +1,53 @@
package com.yihu.editor.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
/**
 * Created by Administrator on 2016.10.17.
 */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Value("${security.basic.username}")
    String username;
    @Value("${security.basic.password}")
    String password;
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .anyRequest().authenticated()
                .and()
                .csrf().disable()
                .formLogin().defaultSuccessUrl("/index").failureUrl("/login") //登录成功之后的跳转
                .permitAll()
                .and()
                .headers().frameOptions().disable()
                .and()
                .logout().logoutSuccessUrl("/login")
                .permitAll();
    }
    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers(
                "/css/**",
                "/lib/**",
                "/img/**",
                "/js/**",
                "/pages/**",
                "/**/*.jsp");
    }
    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
            auth.inMemoryAuthentication()
                .withUser(username).password(password).roles("USER");
    }
}

+ 30 - 26
src/main/java/com/yihu/editor/controller/ArticleController.java

@ -30,7 +30,7 @@ import java.util.UUID;
 * Created by Administrator on 2017/6/9 0009.
 */
@Controller
public class ArticleController extends BaseController{
public class ArticleController extends BaseController {
    @Value("${spring.imageUrl}")
    private String imageUrl;
@ -41,23 +41,23 @@ public class ArticleController extends BaseController{
    public ArticleController() {
    }
    @RequestMapping(value = "/index",method = RequestMethod.GET)
    public String toIndex(){
    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String toIndex() {
        return "index";
    }
    @RequestMapping(value = "/toList",method = RequestMethod.GET)
    public String toList(){
    @RequestMapping(value = "/toList", method = RequestMethod.GET)
    public String toList() {
        return "edit_list";
    }
    @RequestMapping(value = "/toAdd",method = RequestMethod.GET)
    public String toAdd(){
    @RequestMapping(value = "/toAdd", method = RequestMethod.GET)
    public String toAdd() {
        return "add";
    }
    @RequestMapping(value = "/toEdit",method = RequestMethod.GET)
    public String toEdit(@RequestParam(value = "id")String id,ModelMap modelMap){
    @RequestMapping(value = "/toEdit", method = RequestMethod.GET)
    public String toEdit(@RequestParam(value = "id") String id, ModelMap modelMap) {
        YdfHealthEduArticle article = articleService.findById(id);
        modelMap.addAttribute("article", article);
        return "add";
@ -65,9 +65,10 @@ public class ArticleController extends BaseController{
    /**
     * 初始化列表页
     * @param type 意见反馈的类别
     *
     * @param type     意见反馈的类别
     * @param identity 身份
     * @param status 状态
     * @param status   状态
     * @param page
     * @param rows
     * @return
@ -75,13 +76,13 @@ public class ArticleController extends BaseController{
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public String list(
            @RequestParam(required = false,defaultValue = "-1") int type,
            @RequestParam(required = false,defaultValue = "-1") int identity,
            @RequestParam(required = false,defaultValue = "-1") int status,
            @RequestParam(value = "page",defaultValue = "1") int page,
            @RequestParam(value = "rows",defaultValue = "15") int rows) {
            @RequestParam(required = false, defaultValue = "-1") int type,
            @RequestParam(required = false, defaultValue = "-1") int identity,
            @RequestParam(required = false, defaultValue = "-1") int status,
            @RequestParam(value = "page", defaultValue = "1") int page,
            @RequestParam(value = "rows", defaultValue = "15") int rows) {
        try {
            Page<YdfHealthEduArticle> res = articleService.findFeedback(page,rows,type,identity,status);
            Page<YdfHealthEduArticle> res = articleService.findFeedback(page, rows, type, identity, status);
            return write(200, "操作成功", page, rows, res);
        } catch (Exception ex) {
            error(ex);
@ -91,6 +92,7 @@ public class ArticleController extends BaseController{
    /**
     * 获取文章类型
     *
     * @return
     */
    @RequestMapping(value = "/getArticleType")
@ -105,19 +107,21 @@ public class ArticleController extends BaseController{
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    public String save(@ModelAttribute @Valid YdfHealthEduArticle article,HttpServletRequest request,MultipartHttpServletRequest multiReq){
    public String save(@ModelAttribute @Valid YdfHealthEduArticle article, HttpServletRequest request, MultipartHttpServletRequest multiReq) {
        List<MultipartFile> files = multiReq.getFiles("file");
//        String url="http://172.19.103.31:10001/ydf/upload/image";
        String result = Upload.httpClientUploadFile(imageUrl,files);
        JSONObject resultJson = new JSONObject(result);
        String fileUrls = (String) resultJson.get("urls");
        article.setImages(fileUrls);
        if(StringUtils.isBlank(article.getId())){
            article.setId(UUID.randomUUID().toString().replaceAll("-",""));
        if (null != files && files.size() > 0) {
            String result = Upload.httpClientUploadFile(imageUrl, files);
            JSONObject resultJson = new JSONObject(result);
            String fileUrls = (String) resultJson.get("urls");
            article.setImages(fileUrls);
        }
        if (StringUtils.isBlank(article.getId())) {
            article.setId(UUID.randomUUID().toString().replaceAll("-", ""));
        }
        Date date = new Date();
        article.setModifyDate(date);
        if(null==article.getCreateDate()){
        if (null == article.getCreateDate()) {
            article.setCreateDate(date);
        }
        article.setStatus(0);//设置状态
@ -127,7 +131,7 @@ public class ArticleController extends BaseController{
    @RequestMapping(value = "/del")
    @ResponseBody
    public String del(@RequestParam(value = "id")String id){
    public String del(@RequestParam(value = "id") String id) {
        articleService.delete(id);
        return write(200, "删除成功");
    }

+ 0 - 10
src/main/java/com/yihu/editor/entity/YdfHealthEduArticle.java

@ -34,7 +34,6 @@ public class YdfHealthEduArticle {
    private Integer type;
    private String delUserName;
    private String delUser;
    private String saasId;
    @Id
    @Column(name = "id")
@ -235,13 +234,4 @@ public class YdfHealthEduArticle {
        this.delUser = delUser;
    }
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
}

+ 71 - 2
src/main/resources/application.yml

@ -2,10 +2,80 @@ application:
  message: editor
server:
  context-path: /editor
  port: 80
  port: 8082
  session-timeout:  3000
security:
  basic:
    username: jkzl
    password: jkzlehr
---
spring:
  profiles: test
  #调用ydf后台上传图片接口
  imageUrl: http://172.19.103.31:10001/ydf/upload/image
  datasource:
    url: jdbc:mysql://172.19.103.77:3306/ydf?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: root
    password: 123456
    driverClassName: com.mysql.jdbc.Driver
  # Specify the DBMS
  http:
    encoding:
      charset: UTF-8
      enabled: true
  jpa:
    database: MYSQL
    show-sql: true
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQL5Dialect
    hibernate:
      naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
  mvc:
    view:
      prefix: /pages/
      suffix: .jsp
---
spring:
  profiles: prod
  #调用ydf后台上传图片接口
  imageUrl: http://127.0.0.1:8080/ydf/upload/image
  datasource:
    url: jdbc:mysql://127.0.0.1/ydf?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
    username: ydf
    password: Ng#8tW*5M9
    driverClassName: com.mysql.jdbc.Driver
  # Specify the DBMS
  http:
    encoding:
      charset: UTF-8
      enabled: true
  jpa:
    database: MYSQL
    show-sql: true
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQL5Dialect
    hibernate:
      naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
  mvc:
    view:
      prefix: /pages/
      suffix: .jsp
---
spring:
  profiles: dev
  #调用ydf后台上传图片接口
  imageUrl: http://172.19.103.31:10001/ydf/upload/image
  datasource:
    url: jdbc:mysql://172.19.103.77:3306/ydf?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
@ -24,7 +94,6 @@ spring:
      hibernate:
        dialect: org.hibernate.dialect.MySQL5Dialect
    hibernate:
      ddl-auto: update
      naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
  mvc:

+ 1 - 1
src/main/webapp/pages/add.jsp

@ -43,7 +43,7 @@
</head>
<body>
    <form  id="article"   enctype="multipart/form-data" method="post" onsubmit="return sub()">
    <form  id="article" enctype="multipart/form-data" method="post" onsubmit="return sub()">
        <div class="liger-form">
            <div class="content">
                <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0">