فهرست منبع

Merge branch 'master' of chendi/editor into master

chenyongxing 7 سال پیش
والد
کامیت
d7c9e7619e

+ 0 - 2
pom.xml

@ -117,8 +117,6 @@
			<artifactId>httpmime</artifactId>
			<version>4.5.3</version>
		</dependency>
	</dependencies>
	
	<build>

+ 11 - 4
src/main/java/com/yihu/editor/controller/ArticleController.java

@ -9,6 +9,7 @@ import com.yihu.editor.util.Upload;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@ -18,8 +19,11 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
/**
@ -28,10 +32,15 @@ import java.util.UUID;
@Controller
public class ArticleController extends BaseController{
    @Value("${spring.imageUrl}")
    private String imageUrl;
    @Autowired
    private ArticleService articleService;
    public ArticleController() {
    }
    @RequestMapping(value = "/index",method = RequestMethod.GET)
    public String toIndex(){
        return "index";
@ -98,9 +107,8 @@ public class ArticleController extends BaseController{
    @ResponseBody
    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(url,files);
//        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);
@ -113,7 +121,6 @@ public class ArticleController extends BaseController{
            article.setCreateDate(date);
        }
        article.setStatus(0);//设置状态
        article.setType(0);//设置成待审核状态
        articleService.save(article);
        return write(200, "保存成功");
    }

+ 1 - 1
src/main/java/com/yihu/editor/service/ArticleService.java

@ -37,7 +37,7 @@ public class ArticleService {
            rows = 15;
        }
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "id");
        Sort sort = new Sort(Sort.Direction.DESC, "createDate");
        // 分页信息
        PageRequest pageRequest = new PageRequest(page - 1, rows, sort);
        // 设置查询条件

+ 67 - 56
src/main/webapp/pages/add.jsp

@ -9,6 +9,8 @@
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <link href="lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="css/jquery.filer.css" rel="stylesheet" type="text/css" />
    <link href="css/jquery-filer.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery/jquery-2.1.1.min.js"></script>
    <script src="lib/ligerUI/js/core/base.js" type="text/javascript"></script>
    <script src="lib/ligerUI/js/plugins/ligerComboBox.js"></script>
@ -46,58 +48,59 @@
            <div class="content">
                <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td width="30%" class="td-left"><label>标&emsp;&emsp;题:</label></td>
                        <td width="70%" class="td-right">
                        <td width="20%" class="td-left"><label>标&emsp;&emsp;题:</label></td>
                        <td width="80%" class="td-right">
                            <input class="liger-textbox width350" name="title" data-label="标题" required="required" value="${article.title}" />
                            <input type="hidden" value="${article.id}" name="id" id="id">
                        </td>
                    </tr>
                    <tr>
                        <td width="30%" class="td-left"><label>文章类型:</label></td>
                        <td width="70%" class="td-right">
                        <td width="20%" class="td-left"><label>文章类型:</label></td>
                        <td width="80%" class="td-right">
                            <input id="typeSelect"/>
                            <input type="hidden" name="type" id="type" value="${article.type}"/>
                            <input type="hidden" name="typeName" id="typeName" value="${article.typeName}"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="30%" class="td-left"><label>文章来源:</label></td>
                        <td width="70%" class="td-right">
                        <td width="20%" class="td-left"><label>文章来源:</label></td>
                        <td width="80%" class="td-right">
                            <input id="articleFrom"  required="required" />
                        </td>
                    </tr>
                    <tr class="fromUrl hidden">
                        <td width="30%" class="td-left">
                        <td width="20%" class="td-left">
                            URL:
                        </td>
                        <td width="70%" class="td-right">
                        <td width="80%" class="td-right">
                            <input type="url" id="url" name="url"  class="liger-textbox" class="width350" value="${article.url}"/>
                        </td>
                    </tr>
                    <tr class="bySelf hidden">
                        <td width="30%" class="td-left">
                        <td width="20%" class="td-left">
                            关&ensp;键&ensp;字:
                        </td>
                        <td width="70%" class="td-right">
                        <td width="80%" class="td-right">
                            <input name="keyword" class="liger-textbox" class="width350"value="${article.keyword}"/>
                        </td>
                    </tr>
                    <tr class="bySelf hidden">
                        <td width="30%" class="td-left"><label class="bySelf hidden">简&emsp;&emsp;介:</label></td>
                        <td width="70%" class="td-right">
                            <div class="width350"><textarea class="ad-padd" name="contentFirst" placeholder="简介" ></textarea></div>
                        <td width="20%" class="td-left"><label class="bySelf hidden">简&emsp;&emsp;介:</label></td>
                        <td width="80%" class="td-right">
                            <div class="width350"><textarea class="ad-padd" name="contentFirst" placeholder="简介" >${article.contentFirst}</textarea></div>
                        </td>
                    </tr>
                    <tr class="bySelf hidden">
                        <td colspan="2">
                            <div  style="width: 80%;margin:0 auto;"><textarea id="TextArea1"  cols="20" rows="2" name="ckeditor" class="ckeditor"></textarea></div>
                        <td width="20%" class="td-left"><label class="bySelf hidden">内&emsp;&emsp;容:</label></td>
                        <td width: 80%;>
                            <div  style="width: 80%;"><textarea id="TextArea1"  cols="20" rows="2" name="ckeditor" class="ckeditor">${article.content}</textarea></div>
                            <input  type="hidden" name="content" id="content" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                        <td width="20%" class="td-left"><label>上传图片:</label></td>
                        <td width="80%" class="td-right">
                            <input type="file" id="imgFile" name="file" multiple="multiple" class="mui-pull-right">
                            <input type="button" id="uploadFile" value="上传" style="width: 80px;"/>
                        </td>
                    </tr>
                    <tr>
@ -115,40 +118,40 @@
    </form>
</body>
<script>
    $(document).ready(function(){
        var urlVal = $("#url").val();
        if(urlVal != ''){
            $(".fromUrl").each(function(){
                $(this).removeClass("hidden");
                $(".bySelf").each(function(){
                    $(this).addClass("hidden");
                })
            })
            $("#url").attr("required",true);//设置url必输
        }else{
            $(".bySelf").each(function(){
                $(this).removeClass("hidden");
                $(".fromUrl").each(function(){
                    $(this).addClass("hidden");
                })
            })
            if(typeof($("#url").attr("required"))!=="undefined"){
                $("#url").attr("required",false);//取消设置url必输
            }
        }
    });
    var url = $("#url").val();
    function call(data){
        debugger
        alert(data.city);
    }
    $("#uploadFile").click(function(){
        //jFiler-item-thumb-image
        $.ajax({
        type: "JSONP", //必须用post
        url: "http://172.19.103.31:10001/ydf17-6-10/upload/image?callback=call",
        crossDomain: true,
        data: files,
        contentType: false, //必须
        processData: false,
        //不能用success,否则不执行
        complete: function (data) {
            debugger
            var data = eval(data.responseText);
            console.log(data.Data);
        },
            success: function(data){
            debugger
            }
    });
    })
    $("#typeSelect").ligerComboBox(
    var typeSelect = $("#typeSelect").ligerComboBox(
        {
            url:"getArticleType",
            valueField: 'code',
            textField: 'name',
            selectBoxWidth: 400,
            value:'${article.type}',
            onSelected:function(value,text){
                $("#type").val(value);
                $("#typeName").val(text);
@ -165,6 +168,10 @@
                valueField: 'id',
                textField: 'name',
                selectBoxWidth: 400,
                value:function(){
                    var urlVal = $("#url").val();
                    return urlVal? 1:2;
                },
                onSelected:function(value,text){
                    if(value==1){
                        $(".fromUrl").each(function(){
@ -245,7 +252,7 @@
        $(obj).filer({
            changeInput: '<div class="mui-table-view-cell my-table-col-2 img-row">\
				 		<span>'+titleName+'</span>\
				 		<span><img style="width:75px;height:50px;" class="head-img mui-action-preview" src="img/add_img.png"/></span></div>',
				 		<span><img style="width:75px;height:50px;margin-top: 10px;" class="head-img mui-action-preview" src="img/add_img.png"/></span></div>',
            showThumbs: true,
            addMore: true,
            limit: maxfiles,
@ -253,19 +260,21 @@
            extensions: ['jpg', 'jpeg', 'png', 'gif'],
            templates: {
                box: '<ul class="jFiler-items-list jFiler-items-grid"></ul>',
                item: '<li class="jFiler-item" style="width:50%;float:left;">\
                item: '<li class="jFiler-item" style="width:200px;float:left;">\
		                        <div class="jFiler-item-container">\
		                        <div class="jFiler-item-inner">\
		                            <div class="jFiler-item-thumb">\
		                                <div class="jFiler-item-status"></div>\
		                                <a href="#"  class="'+obj.slice(1)+'">{{fi-image}}</a>\
		                            </div>\
		                            <div class="jFiler-item-assets jFiler-row jFiler-item-trash-action">\
		                            	<ul class="list-inline pull-left"></ul>\
		                                <ul class="list-inline pull-right">\
		                                    <li><a class="icon-jfi-trash"></a></li>\
		                                </ul>\
		                            </div>\
		                             <div class="jFiler-item-assets jFiler-row">\
                                        <ul class="list-inline pull-left">\
                                            <li>{{fi-progressBar}}</li>\
                                        </ul>\
                                        <ul class="list-inline pull-right">\
                                            <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                        </ul>\
                                    </div>\
		                        </div>\
		                    </div>\
               			 </li>',
@ -276,12 +285,14 @@
			                                    <div class="jFiler-item-status"></div>\
			                                    <a href="" data-rel="colorbox" class="cboxElement">{{fi-image}}</a>\
			                                </div>\
			                                <div class="jFiler-item-assets jFiler-row jFiler-item-trash-action">\
			                                	<ul class="list-inline pull-left"></ul>\
			                                    <ul class="list-inline pull-right">\
			                                        <li><a class="icon-jfi-trash"></a></li>\
			                                    </ul>\
			                                </div>\
			                                 <div class="jFiler-item-assets jFiler-row">\
                                                <ul class="list-inline pull-left">\
                                                    <li><span class="jFiler-item-others">{{fi-icon}}</span></li>\
                                                </ul>\
                                                <ul class="list-inline pull-right">\
                                                    <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                                </ul>\
                                            </div>\
			                            </div>\
			                        </div>\
			                    </li>',
@ -322,6 +333,6 @@
            }
        });
    };
    uploadDropzone("#imgFile", '上传图片', 5, "file", bx_files);
    uploadDropzone("#imgFile", '', 5, "file", bx_files);
</script>
</html>

+ 7 - 2
src/main/webapp/pages/edit_list.jsp

@ -47,7 +47,9 @@
                {display: '标题', name: 'title', minWidth: 60},
                {display: '简介', name: 'contentFirst', minWidth: 60},
                {display: '关键字', name: 'keyword', minWidth: 60},
                {display: '类型', name: 'typeName', minWidth: 60},
                {display: '类型', name: 'typeName', minWidth: 60, render: function (row,rowIndex) {
                    return row.typeName;
                }},
                {
                    display: '操作', name: 'operator',
                    render: function (row) {
@ -70,7 +72,10 @@
                shadeClose: true,
                shade: 0.8,
                area: ['90%', '90%'],
                content: 'toAdd' //iframe的url
                content: 'toAdd', //iframe的url
                end: function(){
                    location.reload();
                }
            });
        });