Quellcode durchsuchen

文章的相关产品

XMTT vor 6 Jahren
Ursprung
Commit
fafa3c78f3

+ 11 - 0
src/main/java/com/ekexiu/portal/dao/ArticleDao.java

@ -1,6 +1,7 @@
1 1
package com.ekexiu.portal.dao;
2 2

3 3
import com.ekexiu.portal.po.Article;
4
import com.ekexiu.portal.po.ArticleProduct;
4 5
import com.ekexiu.portal.po.ArticleWare;
5 6
import com.ekexiu.portal.pojo.FindInfo;
6 7
import com.ekexiu.portal.pojo.SelfArticle;
@ -57,10 +58,17 @@ public abstract class ArticleDao {
57 58
	@Insert
58 59
	public abstract int insert(Connection con, ArticleWare ware) throws SQLException;
59 60

61
	@Insert
62
	public abstract int insert(Connection con, ArticleProduct articleProduct)throws SQLException;
63

60 64
	@DeleteWith
61 65
	@From(ArticleWare.class)
62 66
	public abstract int deleteWare(Connection con, String id) throws SQLException;
63 67

68
	@DeleteWith
69
	@From(ArticleProduct.class)
70
	public abstract int deleteProduct(Connection con, String id) throws SQLException;
71

64 72
	@UpdateWith
65 73
	@From(Article.class)
66 74
	@SetSentence("PAGE_VIEWS = PAGE_VIEWS + 1")
@ -232,6 +240,9 @@ public abstract class ArticleDao {
232 240
	@SelectList
233 241
	public abstract List<ArticleWare> queryWares(Connection con, String id) throws SQLException;
234 242

243
	@SelectList
244
	public abstract List<ArticleProduct> queryProduct(Connection con, String id) throws SQLException;
245

235 246
	public String[] queryArticleIdWithSameKeyWord(Connection con, String id, int rows) throws SQLException {
236 247
		List<String> ret = new ArrayList<String>();
237 248
		String sql = "select id,count(1) sort from art_key_word where kw in (select kw from art_key_word where id=?) and id <>? group by id order by sort desc limit ?";

+ 32 - 0
src/main/java/com/ekexiu/portal/po/ArticleProduct.java

@ -0,0 +1,32 @@
1
package com.ekexiu.portal.po;
2
3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.Table;
5
import org.jfw.apt.orm.core.enums.DE;
6
7
/**
8
 * Created by TT on 2018/7/11.
9
 */
10
@Table
11
public class ArticleProduct {
12
    private String id;
13
    private String product;
14
15
    @Column(DE.text_de)
16
    public String getId() {
17
        return id;
18
    }
19
20
    public void setId(String id) {
21
        this.id = id;
22
    }
23
24
    @Column(DE.text_de)
25
    public String getProduct() {
26
        return product;
27
    }
28
29
    public void setProduct(String product) {
30
        this.product = product;
31
    }
32
}

+ 64 - 3
src/main/java/com/ekexiu/portal/service/ArticleService.java

@ -20,6 +20,7 @@ import com.ekexiu.portal.po.Article;
20 20
import com.ekexiu.portal.po.ArticleAgree;
21 21
import com.ekexiu.portal.po.ArticleOrg;
22 22
import com.ekexiu.portal.po.ArticlePro;
23
import com.ekexiu.portal.po.ArticleProduct;
23 24
import com.ekexiu.portal.po.ArticleRes;
24 25
import com.ekexiu.portal.po.ArticleWare;
25 26
import com.ekexiu.portal.po.Image;
@ -377,7 +378,7 @@ public class ArticleService {
377 378
	@Post
378 379
	@Path("/save")
379 380
	public String saveArticle(@JdbcConn(false) Connection con, Article article,@Nullable String[] files,@Nullable String[] professors, @Nullable String[] resources,
380
			@Nullable String[] orgs, @Nullable String[] wares) throws SQLException, IOException, JfwBaseException {
381
			@Nullable String[] orgs, @Nullable String[] wares,@Nullable String[] products) throws SQLException, IOException, JfwBaseException {
381 382
		String articleId = null;
382 383
		try {
383 384

@ -434,6 +435,15 @@ public class ArticleService {
434 435
						articleDao.insert(con, aw);
435 436
					}
436 437
				}
438
				articleDao.deleteProduct(con, article.getArticleId());
439
				if (products != null && products.length > 0) {
440
					for (String pid : products) {
441
						ArticleProduct ap = new ArticleProduct();
442
						ap.setId(articleId);
443
						ap.setProduct(pid);
444
						articleDao.insert(con, ap);
445
					}
446
				}
437 447
			} else if (article.getArticleId().trim().length() == 32) {
438 448
				articleId = article.getArticleId();
439 449
				if (article.getArticleImg() != null) {
@ -480,6 +490,15 @@ public class ArticleService {
480 490
						articleDao.insert(con, aw);
481 491
					}
482 492
				}
493
				articleDao.deleteProduct(con, article.getArticleId());
494
				if (products != null && products.length > 0) {
495
					for (String pid : products) {
496
						ArticleProduct ap = new ArticleProduct();
497
						ap.setId(articleId);
498
						ap.setProduct(pid);
499
						articleDao.insert(con, ap);
500
					}
501
				}
483 502
			} else {
484 503
				throw new JfwBaseException(-2, "bad parameter:articleId");
485 504
			}
@ -498,7 +517,7 @@ public class ArticleService {
498 517
	@Post
499 518
	@Path("/draft")
500 519
	public String draft(@JdbcConn(false) Connection con, Article article,@Nullable String[] files, @Nullable String[] professors, @Nullable String[] resources, @Nullable String[] orgs,
501
			@Nullable String[] wares) throws SQLException, IOException, JfwBaseException {
520
			@Nullable String[] wares,@Nullable String[] products) throws SQLException, IOException, JfwBaseException {
502 521

503 522
		String articleId = null;
504 523
		try {
@ -554,6 +573,15 @@ public class ArticleService {
554 573
						articleDao.insert(con, aw);
555 574
					}
556 575
				}
576
				articleDao.deleteProduct(con, article.getArticleId());
577
				if (products != null && products.length > 0) {
578
					for (String pid : products) {
579
						ArticleProduct ap = new ArticleProduct();
580
						ap.setId(articleId);
581
						ap.setProduct(pid);
582
						articleDao.insert(con, ap);
583
					}
584
				}
557 585
			} else if (article.getArticleId().trim().length() == 32) {
558 586
				articleId = article.getArticleId();
559 587
				if (article.getArticleImg() != null) {
@ -600,6 +628,15 @@ public class ArticleService {
600 628
						articleDao.insert(con, aw);
601 629
					}
602 630
				}
631
				articleDao.deleteProduct(con, article.getArticleId());
632
				if (products != null && products.length > 0) {
633
					for (String pid : products) {
634
						ArticleProduct ap = new ArticleProduct();
635
						ap.setId(articleId);
636
						ap.setProduct(pid);
637
						articleDao.insert(con, ap);
638
					}
639
				}
603 640
			} else {
604 641
				throw new JfwBaseException(-2, "bad parameter:articleId");
605 642
			}
@ -618,7 +655,7 @@ public class ArticleService {
618 655
	@Post
619 656
	@Path("/timing")
620 657
	public String timingPublish(@JdbcConn(false) Connection con, Article article,@Nullable String[] files, @Nullable String[] professors, @Nullable String[] resources,
621
			@Nullable String[] orgs, @Nullable String[] wares) throws SQLException, IOException, JfwBaseException {
658
			@Nullable String[] orgs, @Nullable String[] wares,@Nullable String[] products) throws SQLException, IOException, JfwBaseException {
622 659
		String articleId = null;
623 660
		try {
624 661
			if (article.getPublishTime() == null) {
@ -675,6 +712,15 @@ public class ArticleService {
675 712
						articleDao.insert(con, aw);
676 713
					}
677 714
				}
715
				articleDao.deleteProduct(con, article.getArticleId());
716
				if (products != null && products.length > 0) {
717
					for (String pid : products) {
718
						ArticleProduct ap = new ArticleProduct();
719
						ap.setId(articleId);
720
						ap.setProduct(pid);
721
						articleDao.insert(con, ap);
722
					}
723
				}
678 724
			} else if (article.getArticleId().trim().length() == 32) {
679 725
				articleId = article.getArticleId();
680 726
				if (article.getArticleImg() != null) {
@ -722,6 +768,15 @@ public class ArticleService {
722 768
						articleDao.insert(con, aw);
723 769
					}
724 770
				}
771
				articleDao.deleteProduct(con, article.getArticleId());
772
				if (products != null && products.length > 0) {
773
					for (String pid : products) {
774
						ArticleProduct ap = new ArticleProduct();
775
						ap.setId(articleId);
776
						ap.setProduct(pid);
777
						articleDao.insert(con, ap);
778
					}
779
				}
725 780
			} else {
726 781
				throw new JfwBaseException(-2, "bad parameter:articleId");
727 782
			}
@ -1202,6 +1257,12 @@ public class ArticleService {
1202 1257
		return articleDao.queryWares(con, id);
1203 1258
	}
1204 1259

1260
	@Get
1261
	@Path("/product")
1262
	public List<ArticleProduct> queryProducts(@JdbcConn Connection con,String id)throws SQLException {
1263
		return articleDao.queryProduct(con, id);
1264
	}
1265

1205 1266
	@Get
1206 1267
	@Path("/count/publish")
1207 1268
	public long countPublish(@JdbcConn Connection con,String category,String owner)throws SQLException {