From 2928db4614fc87f16b6197cef42f50d203c4386e Mon Sep 17 00:00:00 2001 From: qushutong <1976590620@qq.com> Date: Thu, 5 Sep 2019 09:19:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E9=97=BB=E7=B1=BB=E5=88=AB=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epdc-news/epdc-news-client/pom.xml | 8 +- .../elink/esua/epdc/dto/NewsCategoryDTO.java | 66 +++++++++++ .../epdc-news/epdc-news-server/pom.xml | 12 +- .../controller/NewsCategoryController.java | 94 ++++++++++++++++ .../elink/esua/epdc/dao/NewsCategoryDao.java | 33 ++++++ .../esua/epdc/entity/NewsCategoryEntity.java | 61 ++++++++++ .../esua/epdc/excel/NewsCategoryExcel.java | 68 ++++++++++++ .../esua/epdc/redis/NewsCategoryRedis.java | 47 ++++++++ .../epdc/service/NewsCategoryService.java | 95 ++++++++++++++++ .../service/impl/NewsCategoryServiceImpl.java | 104 ++++++++++++++++++ .../main/resources/mapper/NewsCategoryDao.xml | 21 ++++ 11 files changed, 602 insertions(+), 7 deletions(-) create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsCategoryDTO.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsCategoryController.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NewsCategoryDao.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NewsCategoryEntity.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NewsCategoryExcel.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NewsCategoryRedis.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsCategoryService.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsCategoryServiceImpl.java create mode 100644 esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsCategoryDao.xml diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/pom.xml b/esua-epdc/epdc-module/epdc-news/epdc-news-client/pom.xml index 5d569d869..0b6f88f85 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-client/pom.xml +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/pom.xml @@ -12,5 +12,11 @@ epdc-news-client jar - + + + com.esua.epdc + epdc-commons-tools + 1.0.0 + + \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsCategoryDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsCategoryDTO.java new file mode 100644 index 000000000..316df4ede --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsCategoryDTO.java @@ -0,0 +1,66 @@ +/** + * 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-04 + */ +@Data +public class NewsCategoryDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 类别名称 + */ + private String categoryName; + + /** + * 类别编码 + */ + private String categoryCode; + + /** + * 描述 + */ + private String description; + + /** + * 排序 + */ + private Integer sort; + + private Integer revision; + + private String createdBy; + + private Date createdTime; + + private String updatedBy; + + private Date updatedTime; + + private String delFlag; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/pom.xml b/esua-epdc/epdc-module/epdc-news/epdc-news-server/pom.xml index 5f544151b..2e0a3b66b 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/pom.xml +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/pom.xml @@ -86,10 +86,10 @@ elink@888 - + epdc - elink888 + elink833066 false 47.104.224.45:8848 @@ -109,10 +109,10 @@ elink@888 - + epdc - elink888 + elink833066 false 47.104.224.45:8848 @@ -132,10 +132,10 @@ elink@888 - + epdc - elink888 + elink833066 false 47.104.224.45:8848 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 new file mode 100644 index 000000000..69a21af14 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsCategoryController.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.news.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.NewsCategoryDTO; +import com.elink.esua.epdc.excel.NewsCategoryExcel; +import com.elink.esua.epdc.service.NewsCategoryService; +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-04 + */ +@RestController +@RequestMapping("newscategory") +public class NewsCategoryController { + + @Autowired + private NewsCategoryService newsCategoryService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = newsCategoryService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + NewsCategoryDTO data = newsCategoryService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody NewsCategoryDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + newsCategoryService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody NewsCategoryDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + newsCategoryService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + newsCategoryService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = newsCategoryService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, NewsCategoryExcel.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/NewsCategoryDao.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NewsCategoryDao.java new file mode 100644 index 000000000..15d1c1718 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NewsCategoryDao.java @@ -0,0 +1,33 @@ +/** + * 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.NewsCategoryEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 新闻类别表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-04 + */ +@Mapper +public interface NewsCategoryDao extends BaseDao { + +} \ 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/NewsCategoryEntity.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NewsCategoryEntity.java new file mode 100644 index 000000000..a8e16d956 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NewsCategoryEntity.java @@ -0,0 +1,61 @@ +/** + * 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-04 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_news_category") +public class NewsCategoryEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 类别名称 + */ + private String categoryName; + + /** + * 类别编码 + */ + private String categoryCode; + + /** + * 描述 + */ + private String description; + + /** + * 排序 + */ + private Integer sort; + +} \ 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/NewsCategoryExcel.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NewsCategoryExcel.java new file mode 100644 index 000000000..611084ab8 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NewsCategoryExcel.java @@ -0,0 +1,68 @@ +/** + * 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-04 + */ +@Data +public class NewsCategoryExcel { + + @Excel(name = "ID") + private String id; + + @Excel(name = "类别名称") + private String categoryName; + + @Excel(name = "类别编码") + private String categoryCode; + + @Excel(name = "描述") + private String description; + + @Excel(name = "排序") + private Integer sort; + + @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; + + +} \ 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/NewsCategoryRedis.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NewsCategoryRedis.java new file mode 100644 index 000000000..c2d90ac5c --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NewsCategoryRedis.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.news.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-04 + */ +@Component +public class NewsCategoryRedis { + @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 new file mode 100644 index 000000000..502d49b3a --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsCategoryService.java @@ -0,0 +1,95 @@ +/** + * 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.NewsCategoryDTO; +import com.elink.esua.epdc.entity.NewsCategoryEntity; + +import java.util.List; +import java.util.Map; + +/** + * 新闻类别表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-04 + */ +public interface NewsCategoryService 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 NewsCategoryDTO + * @author + * @date + */ + NewsCategoryDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author + * @date + */ + void save(NewsCategoryDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author + * @date + */ + void update(NewsCategoryDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author + * @date + */ + void delete(String[] ids); +} \ 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 new file mode 100644 index 000000000..5d237b3c2 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsCategoryServiceImpl.java @@ -0,0 +1,104 @@ +/** + * 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.news.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.NewsCategoryDao; +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 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-04 + */ +@Service +public class NewsCategoryServiceImpl extends BaseServiceImpl implements NewsCategoryService { + + @Autowired + private NewsCategoryRedis newsCategoryRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, NewsCategoryDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, NewsCategoryDTO.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 NewsCategoryDTO get(String id) { + NewsCategoryEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, NewsCategoryDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(NewsCategoryDTO dto) { + NewsCategoryEntity entity = ConvertUtils.sourceToTarget(dto, NewsCategoryEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(NewsCategoryDTO dto) { + NewsCategoryEntity entity = ConvertUtils.sourceToTarget(dto, NewsCategoryEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsCategoryDao.xml b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsCategoryDao.xml new file mode 100644 index 000000000..2fad90ac9 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsCategoryDao.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file