From 03ee5bd0b75d8e8b8dadb9c75f581a5d96f0e789 Mon Sep 17 00:00:00 2001 From: qushutong <1976590620@qq.com> Date: Thu, 5 Sep 2019 17:07:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E9=97=BB=E7=B1=BB=E5=88=AB=E5=B7=B2?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/elink/esua/epdc/dto/NewsDTO.java | 176 ++++++++++++++++++ .../controller/NewsCategoryController.java | 6 + .../esua/epdc/controller/NewsController.java | 94 ++++++++++ .../java/com/elink/esua/epdc/dao/NewsDao.java | 34 ++++ .../elink/esua/epdc/entity/NewsEntity.java | 146 +++++++++++++++ .../com/elink/esua/epdc/excel/NewsExcel.java | 119 ++++++++++++ .../com/elink/esua/epdc/redis/NewsRedis.java | 47 +++++ .../epdc/service/NewsCategoryService.java | 9 +- .../elink/esua/epdc/service/NewsService.java | 102 ++++++++++ .../service/impl/NewsCategoryServiceImpl.java | 10 + .../epdc/service/impl/NewsServiceImpl.java | 110 +++++++++++ .../src/main/resources/mapper/NewsDao.xml | 45 +++++ .../src/main/resources/generator.properties | 4 +- 13 files changed, 898 insertions(+), 4 deletions(-) create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsDTO.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsController.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NewsDao.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NewsEntity.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NewsExcel.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NewsRedis.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsService.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsDao.xml diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsDTO.java new file mode 100644 index 000000000..37825350b --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsDTO.java @@ -0,0 +1,176 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 新闻表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Data +public class NewsDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 新闻标题 + */ + private String newsTitle; + + /** + * 新闻内容 + */ + private String newsContent; + + /** + * 新闻类别ID + */ + private String newsCateroryId; + + /** + * 新闻属性 + */ + private String newsProperty; + + /** + * 新闻位置ID + */ + private String newsPositionId; + + /** + * 新闻主图 + */ + private String newsImageUrl; + + /** + * 新闻上下线状态 0-下线,1-上线 + */ + private String newsUpDownState; + + /** + * 新闻发布开始时间 + */ + private Date newsReleaseStartTime; + + /** + * 新闻发布结束时间 + */ + private Date newsReleaseEndTime; + + /** + * 发布人部门 + */ + private String deptName; + + /** + * 发布人部门ID + */ + private String deptId; + + /** + * 阅读量 + */ + private Integer readingAmount; + + /** + * 点赞数 + */ + private Integer likeNumber; + + /** + * 点踩数 + */ + private Integer unLikeNumber; + + /** + * 删除标识 0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 通知所属街道 + */ + private String street; + + /** + * 通知所属街道ID + */ + private Long streetId; + + /** + * 通知所属社区 + */ + private String community; + + /** + * 通知所属社区ID + */ + private Long communityId; + + /** + * 通知所属网格 + */ + private String grid; + + /** + * 通知所属网格ID + */ + private Long gridId; + + /** + * 创建人姓名 + */ + private String creatorName; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsCategoryController.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsCategoryController.java index e5c97696b..48014f406 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsCategoryController.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsCategoryController.java @@ -79,6 +79,9 @@ public class NewsCategoryController { public Result update(@RequestBody NewsCategoryDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + if(newsCategoryService.checkIsExist(dto.getId())){ + return new Result().error("该类别下存在新闻不允许删除"); + } if(newsCategoryService.checkCodeCategory(dto.getCategoryCode(),dto.getId())>0){ return new Result().error("类别编码已存在"); } @@ -93,6 +96,9 @@ public class NewsCategoryController { public Result delete(@RequestBody String[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); + if(newsCategoryService.checkIsExist(ids[0])){ + return new Result().error("该类别下存在新闻不允许删除"); + } newsCategoryService.delete(ids); return new Result(); } diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsController.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsController.java new file mode 100644 index 000000000..3551e9a71 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsController.java @@ -0,0 +1,94 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.controller; + +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.commons.tools.validator.AssertUtils; +import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; +import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; +import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; +import com.elink.esua.epdc.dto.NewsDTO; +import com.elink.esua.epdc.excel.NewsExcel; +import com.elink.esua.epdc.service.NewsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 新闻表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@RestController +@RequestMapping("news") +public class NewsController { + + @Autowired + private NewsService newsService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = newsService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + NewsDTO data = newsService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody NewsDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + newsService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody NewsDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + newsService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + newsService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = newsService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, NewsExcel.class); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NewsDao.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NewsDao.java new file mode 100644 index 000000000..a66e75c97 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NewsDao.java @@ -0,0 +1,34 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.entity.NewsEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 新闻表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Mapper +public interface NewsDao extends BaseDao { + + int selectCountByCategoryId(String categoryId); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NewsEntity.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NewsEntity.java new file mode 100644 index 000000000..9330e0416 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NewsEntity.java @@ -0,0 +1,146 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 新闻表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_news") +public class NewsEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 新闻标题 + */ + private String newsTitle; + + /** + * 新闻内容 + */ + private String newsContent; + + /** + * 新闻类别ID + */ + private String newsCateroryId; + + /** + * 新闻属性 + */ + private String newsProperty; + + /** + * 新闻位置ID + */ + private String newsPositionId; + + /** + * 新闻主图 + */ + private String newsImageUrl; + + /** + * 新闻上下线状态 0-下线,1-上线 + */ + private String newsUpDownState; + + /** + * 新闻发布开始时间 + */ + private Date newsReleaseStartTime; + + /** + * 新闻发布结束时间 + */ + private Date newsReleaseEndTime; + + /** + * 发布人部门 + */ + private String deptName; + + /** + * 发布人部门ID + */ + private String deptId; + + /** + * 阅读量 + */ + private Integer readingAmount; + + /** + * 点赞数 + */ + private Integer likeNumber; + + /** + * 点踩数 + */ + private Integer unLikeNumber; + + /** + * 通知所属街道 + */ + private String street; + + /** + * 通知所属街道ID + */ + private Long streetId; + + /** + * 通知所属社区 + */ + private String community; + + /** + * 通知所属社区ID + */ + private Long communityId; + + /** + * 通知所属网格 + */ + private String grid; + + /** + * 通知所属网格ID + */ + private Long gridId; + + /** + * 创建人姓名 + */ + private String creatorName; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NewsExcel.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NewsExcel.java new file mode 100644 index 000000000..1f57f440c --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NewsExcel.java @@ -0,0 +1,119 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 新闻表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Data +public class NewsExcel { + + @Excel(name = "ID") + private String id; + + @Excel(name = "新闻标题") + private String newsTitle; + + @Excel(name = "新闻内容") + private String newsContent; + + @Excel(name = "新闻类别ID") + private String newsCateroryId; + + @Excel(name = "新闻属性") + private String newsProperty; + + @Excel(name = "新闻位置ID") + private String newsPositionId; + + @Excel(name = "新闻主图") + private String newsImageUrl; + + @Excel(name = "新闻上下线状态 0-下线,1-上线") + private String newsUpDownState; + + @Excel(name = "新闻发布开始时间") + private Date newsReleaseStartTime; + + @Excel(name = "新闻发布结束时间") + private Date newsReleaseEndTime; + + @Excel(name = "发布人部门") + private String deptName; + + @Excel(name = "发布人部门ID") + private String deptId; + + @Excel(name = "阅读量") + private Integer readingAmount; + + @Excel(name = "点赞数") + private Integer likeNumber; + + @Excel(name = "点踩数") + private Integer unLikeNumber; + + @Excel(name = "删除标识 0:未删除,1:已删除") + private String delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + @Excel(name = "通知所属街道") + private String street; + + @Excel(name = "通知所属街道ID") + private Long streetId; + + @Excel(name = "通知所属社区") + private String community; + + @Excel(name = "通知所属社区ID") + private Long communityId; + + @Excel(name = "通知所属网格") + private String grid; + + @Excel(name = "通知所属网格ID") + private Long gridId; + + @Excel(name = "创建人姓名") + private String creatorName; + + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NewsRedis.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NewsRedis.java new file mode 100644 index 000000000..ec5c43109 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NewsRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.redis; + +import com.elink.esua.epdc.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 新闻表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Component +public class NewsRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsCategoryService.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsCategoryService.java index f87b4ccbe..39a79c09d 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsCategoryService.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsCategoryService.java @@ -94,12 +94,17 @@ public interface NewsCategoryService extends BaseService { void delete(String[] ids); /** - * + *检查名字是否重复 */ int checkNameCategory(String categoryName,String id); /** - * + *检查标签编码是否重复 */ int checkCodeCategory(String categoryCode,String id); + + /** + * 检查标签下是否存在新闻 + */ + boolean checkIsExist(String id); } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsService.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsService.java new file mode 100644 index 000000000..d239e8905 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsService.java @@ -0,0 +1,102 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.service; + +import com.elink.esua.epdc.commons.mybatis.service.BaseService; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.dto.NewsDTO; +import com.elink.esua.epdc.entity.NewsEntity; + +import java.util.List; +import java.util.Map; + +/** + * 新闻表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +public interface NewsService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author + * @date + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author + * @date + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return NewsDTO + * @author + * @date + */ + NewsDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author + * @date + */ + void save(NewsDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author + * @date + */ + void update(NewsDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author + * @date + */ + void delete(String[] ids); + + + /** + * 查询标签id下有没有新闻 + */ + int checkCountByCategoryId(String categoryId); + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsCategoryServiceImpl.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsCategoryServiceImpl.java index 076efd2dc..77af30885 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsCategoryServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsCategoryServiceImpl.java @@ -28,6 +28,7 @@ import com.elink.esua.epdc.dto.NewsCategoryDTO; import com.elink.esua.epdc.entity.NewsCategoryEntity; import com.elink.esua.epdc.news.redis.NewsCategoryRedis; import com.elink.esua.epdc.service.NewsCategoryService; +import com.elink.esua.epdc.service.NewsService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -49,6 +50,9 @@ public class NewsCategoryServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -92,6 +96,7 @@ public class NewsCategoryServiceImpl extends BaseServiceImpl0?true:false; + } + } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java new file mode 100644 index 000000000..037865242 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java @@ -0,0 +1,110 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; +import com.elink.esua.epdc.commons.tools.constant.FieldConstant; +import com.elink.esua.epdc.dao.NewsDao; +import com.elink.esua.epdc.dto.NewsDTO; +import com.elink.esua.epdc.entity.NewsEntity; +import com.elink.esua.epdc.redis.NewsRedis; +import com.elink.esua.epdc.service.NewsService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 新闻表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Service +public class NewsServiceImpl extends BaseServiceImpl implements NewsService { + + @Autowired + private NewsRedis newsRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, NewsDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, NewsDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public NewsDTO get(String id) { + NewsEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, NewsDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(NewsDTO dto) { + NewsEntity entity = ConvertUtils.sourceToTarget(dto, NewsEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(NewsDTO dto) { + NewsEntity entity = ConvertUtils.sourceToTarget(dto, NewsEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public int checkCountByCategoryId(String categoryId){ + + return baseDao.selectCountByCategoryId(categoryId); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsDao.xml b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsDao.xml new file mode 100644 index 000000000..bddbd02b6 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsDao.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/renren-cloud-generator/src/main/resources/generator.properties b/renren-cloud-generator/src/main/resources/generator.properties index 4bde9bd4d..7cdad8a6b 100644 --- a/renren-cloud-generator/src/main/resources/generator.properties +++ b/renren-cloud-generator/src/main/resources/generator.properties @@ -5,11 +5,11 @@ main= package=com.elink.esua.epdc moduleName=news #\u4F5C\u8005 -author=yujintao +author=qu #\u7248\u672C\u53F7 version=v1.0.0 #Email -email=yujintao@elink-cn.com +email=qu@elink-cn.com #\u8868\u524D\u7F00(\u7C7B\u540D\u4E0D\u4F1A\u5305\u542B\u8868\u524D\u7F00) tablePrefix=epdc_