diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java index 532511b2c..b06fb2bf5 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java @@ -16,6 +16,7 @@ import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; import com.elink.esua.epdc.dto.SysDeptDTO; +import com.elink.esua.epdc.dto.SysSimpleDeptDTO; import com.elink.esua.epdc.service.SysDeptService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -49,11 +50,9 @@ public class SysDeptController { @GetMapping("sublist/{pid}") @ApiOperation("子列表") - public Result> sublist(@PathVariable("pid") String pid){ - Map map = new HashMap(); - map.put("pid",pid); - List list = sysDeptService.subList(map); - return new Result>().ok(list); + public Result> sublist(@PathVariable("pid") String pid){ + List list = sysDeptService.subList(pid); + return new Result().ok(list); } @GetMapping("{id}") diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java index 695c22b2c..17a0c6e8d 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java @@ -40,8 +40,6 @@ public interface SysDeptDao extends BaseDao { */ List getSubDeptIdList(String id); - List getSubList(Map params); - /** * 根据上级部门ID,获取下属部门简要信息列表 * diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java index e992eda68..b8827fbe4 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java @@ -1,13 +1,14 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ package com.elink.esua.epdc.service; +import com.elink.esua.epdc.dto.SysSimpleDeptDTO; import com.elink.esua.epdc.entity.SysDeptEntity; import com.elink.esua.epdc.commons.mybatis.service.BaseService; import com.elink.esua.epdc.dto.SysDeptDTO; @@ -34,12 +35,20 @@ public interface SysDeptService extends BaseService { void delete(Long id); - //根据pid获取下一级子列表 - List subList(Map params); + /** + * 根据部门ID,获取下属部门 + * + * @param pid + * @return java.util.List + * @author + * @date 2019/9/4 20:54 + */ + List subList(String pid); /** * 根据部门ID,获取本部门及子部门ID列表 - * @param id 部门ID + * + * @param id 部门ID */ List getSubDeptIdList(Long id); } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java index ef32e341d..f7d4f545e 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java @@ -1,15 +1,17 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ package com.elink.esua.epdc.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.tools.constant.Constant; +import com.elink.esua.epdc.commons.tools.constant.FieldConstant; import com.elink.esua.epdc.commons.tools.enums.SuperAdminEnum; import com.elink.esua.epdc.commons.tools.exception.ErrorCode; import com.elink.esua.epdc.commons.tools.exception.RenException; @@ -19,6 +21,7 @@ import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; import com.elink.esua.epdc.commons.tools.utils.TreeUtils; import com.elink.esua.epdc.dao.SysDeptDao; import com.elink.esua.epdc.dto.SysDeptDTO; +import com.elink.esua.epdc.dto.SysSimpleDeptDTO; import com.elink.esua.epdc.entity.SysDeptEntity; import com.elink.esua.epdc.service.SysDeptService; import com.elink.esua.epdc.service.SysUserService; @@ -47,7 +50,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl list(Map params) { //普通管理员,只能查询所属部门及子部门的数据 UserDetail user = SecurityUser.getUser(); - if(user.getSuperAdmin() == SuperAdminEnum.NO.value()) { + if (user.getSuperAdmin() == SuperAdminEnum.NO.value()) { params.put("deptIdList", getSubDeptIdList(user.getDeptId())); } @@ -59,16 +62,19 @@ public class SysDeptServiceImpl extends BaseServiceImpl subList(Map params) { - List entityList = baseDao.getSubList(params); - List dtoList = ConvertUtils.sourceToTarget(entityList, SysDeptDTO.class); - return TreeUtils.build(dtoList); + public List subList(String pid) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("pid", pid) + .select(FieldConstant.ID, FieldConstant.NAME) + .orderByAsc(FieldConstant.NAME); + List entities = this.baseDao.selectList(wrapper); + return ConvertUtils.sourceToTarget(entities, SysSimpleDeptDTO.class); } @Override public SysDeptDTO get(Long id) { //超级管理员,部门ID为null - if(id == null){ + if (id == null) { return null; } @@ -92,7 +98,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl subList = getSubDeptIdList(id); - if(subList.size() > 1){ + if (subList.size() > 1) { throw new RenException(ErrorCode.DEPT_SUB_DELETE_ERROR); } //判断部门下面是否有用户 int count = sysUserService.getCountByDeptId(id); - if(count > 0){ + if (count > 0) { throw new RenException(ErrorCode.DEPT_USER_DELETE_ERROR); } @@ -129,11 +135,12 @@ public class SysDeptServiceImpl extends BaseServiceImpl map = new HashMap<>(deptList.size()); - for(SysDeptEntity entity : deptList){ + for (SysDeptEntity entity : deptList) { map.put(entity.getId(), entity); } @@ -155,13 +162,13 @@ public class SysDeptServiceImpl extends BaseServiceImpl map, List pidList) { //顶级部门,无上级部门 - if(Constant.DEPT_ROOT.equals(pid)){ - return ; + if (Constant.DEPT_ROOT.equals(pid)) { + return; } //上级部门存在 SysDeptEntity parent = map.get(pid); - if(parent != null){ + if (parent != null) { getPidTree(parent.getPid(), map, pidList); } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml b/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml index dc5e9d705..60b2345ec 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml @@ -15,10 +15,6 @@ order by t1.sort asc - - + SELECT + e.ID, + e.ISSUE_CONTENT AS issueContent, + i.IMG_URL AS images, + e.NICK_NAME AS nickName, + e.CREATED_TIME AS createdTime + FROM + epdc_events e + LEFT JOIN epdc_img i ON e.ID = i.REFERENCE_ID + AND i.DEL_FLAG = '0' + WHERE + e.DEL_FLAG = '0' + AND e.ID = #{id} + ORDER BY + i.CREATED_TIME + diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml new file mode 100644 index 000000000..c91187d16 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueHandleDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueHandleDao.xml new file mode 100644 index 000000000..d8150fb2b --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueHandleDao.xml @@ -0,0 +1,6 @@ + + + + + + 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 0b6f88f85..35f66a950 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 @@ -19,4 +19,8 @@ 1.0.0 + + + ${project.artifactId} + \ 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/NoticeDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeDTO.java new file mode 100644 index 000000000..e3e21626a --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeDTO.java @@ -0,0 +1,101 @@ +/** + * 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 yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-04 + */ +@Data +public class NoticeDTO implements Serializable { + + private static final long serialVersionUID = 37499709778679686L; + + /** + * 主键 + */ + private String id; + + /** + * 通知标题 + */ + private String noticeTitle; + + /** + * 通知内容 + */ + private String noticeContent; + + /** + * 发布通知者姓名 + */ + private String creatorName; + + /** + * 发布通知部门 + */ + private String dept; + + /** + * 发布通知部门ID + */ + private Long deptId; + + /** + * 阅读量 + */ + private Integer readingAmount; + + /** + * 乐观锁 + */ + 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/src/main/java/com/elink/esua/epdc/controller/NoticeController.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeController.java new file mode 100644 index 000000000..e3c4f9955 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeController.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.NoticeDTO; +import com.elink.esua.epdc.excel.NoticeExcel; +import com.elink.esua.epdc.service.NoticeService; +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 yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-04 + */ +@RestController +@RequestMapping("/notice") +public class NoticeController { + + @Autowired + private NoticeService noticeService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = noticeService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + NoticeDTO data = noticeService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody NoticeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + noticeService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody NoticeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + noticeService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + noticeService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = noticeService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, NoticeExcel.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/NoticeDao.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeDao.java new file mode 100644 index 000000000..6a4b0e7b3 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeDao.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.NoticeEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 通知表 + * + * @author yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-04 + */ +@Mapper +public interface NoticeDao 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/NoticeEntity.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeEntity.java new file mode 100644 index 000000000..f7c6ae639 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeEntity.java @@ -0,0 +1,73 @@ +/** + * 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.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + + +/** + * 通知表 + * + * @author yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-04 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("epdc_notice") +public class NoticeEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = -6126856752206177133L; + + /** + * 通知标题 + */ + private String noticeTitle; + + /** + * 通知内容 + */ + private String noticeContent; + + /** + * 发布通知者姓名 + */ + private String creatorName; + + /** + * 发布通知部门 + */ + private String dept; + + /** + * 发布通知部门ID + */ + @TableField(fill = FieldFill.DEFAULT) + private Long deptId; + + /** + * 阅读量 + */ + private Integer readingAmount; + +} \ 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/NoticeExcel.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NoticeExcel.java new file mode 100644 index 000000000..03ea19e6a --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NoticeExcel.java @@ -0,0 +1,71 @@ +/** + * 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 yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-04 + */ +@Data +public class NoticeExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "通知标题") + private String noticeTitle; + + @Excel(name = "通知内容") + private String noticeContent; + + @Excel(name = "发布通知部门") + private String dept; + + @Excel(name = "发布通知部门ID") + private String deptId; + + @Excel(name = "阅读量") + private Integer readingAmount; + + @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 delFlag; + + +} \ 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/NoticeRedis.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NoticeRedis.java new file mode 100644 index 000000000..4efd050a2 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NoticeRedis.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 yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-04 + */ +@Component +public class NoticeRedis { + @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/NoticeService.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeService.java new file mode 100644 index 000000000..decc5ed48 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeService.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.NoticeDTO; +import com.elink.esua.epdc.entity.NoticeEntity; + +import java.util.List; +import java.util.Map; + +/** + * 通知表 + * + * @author yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-04 + */ +public interface NoticeService 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 NoticeDTO + * @author + * @date + */ + NoticeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author + * @date + */ + void save(NoticeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author + * @date + */ + void update(NoticeDTO 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/NoticeServiceImpl.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeServiceImpl.java new file mode 100644 index 000000000..dbe840fc4 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeServiceImpl.java @@ -0,0 +1,117 @@ +/** + * 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.exception.RenException; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; +import com.elink.esua.epdc.commons.tools.security.user.UserDetail; +import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; +import com.elink.esua.epdc.commons.tools.constant.FieldConstant; +import com.elink.esua.epdc.dao.NoticeDao; +import com.elink.esua.epdc.dto.NoticeDTO; +import com.elink.esua.epdc.entity.NoticeEntity; +import com.elink.esua.epdc.redis.NoticeRedis; +import com.elink.esua.epdc.service.NoticeService; +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 yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-04 + */ +@Service +public class NoticeServiceImpl extends BaseServiceImpl implements NoticeService { + + @Autowired + private NoticeRedis noticeRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, NoticeDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, NoticeDTO.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 NoticeDTO get(String id) { + NoticeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, NoticeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(NoticeDTO dto) { + + UserDetail user = SecurityUser.getUser(); + if (!user.getDeptIdList().contains(dto.getDeptId())) { + throw new RenException("您没有操作此部门的数据权限"); + } + dto.setCreatorName(user.getRealName()); + NoticeEntity entity = ConvertUtils.sourceToTarget(dto, NoticeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(NoticeDTO dto) { + UserDetail user = SecurityUser.getUser(); + if (!user.getDeptIdList().contains(dto.getDeptId())) { + throw new RenException("您没有操作此部门的数据权限"); + } + NoticeEntity entity = ConvertUtils.sourceToTarget(dto, NoticeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + //物理删除 + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/renren-cloud-generator/src/main/java/io/renren/utils/GenUtils.java b/renren-cloud-generator/src/main/java/io/renren/utils/GenUtils.java index b88282d63..46141b46f 100644 --- a/renren-cloud-generator/src/main/java/io/renren/utils/GenUtils.java +++ b/renren-cloud-generator/src/main/java/io/renren/utils/GenUtils.java @@ -37,7 +37,7 @@ import java.util.zip.ZipOutputStream; /** * 代码生成器 工具类 - * + * * @author chenshun * @email sunlightcs@gmail.com */ @@ -58,7 +58,7 @@ public class GenUtils { templates.add("template/add-or-update.vue.vm"); return templates; } - + /** * 生成代码 */ @@ -75,7 +75,7 @@ public class GenUtils { String className = tableToJava(tableEntity.getTableName(), config.getString("tablePrefix")); tableEntity.setClassName(className); tableEntity.setClassname(StringUtils.uncapitalize(className)); - + //列信息 List columsList = new ArrayList<>(); for(Map column : columns){ @@ -84,12 +84,12 @@ public class GenUtils { columnEntity.setDataType(column.get("dataType")); columnEntity.setComments(column.get("columnComment")); columnEntity.setExtra(column.get("extra")); - + //列名转换成Java属性名 String attrName = columnToJava(columnEntity.getColumnName()); columnEntity.setAttrName(attrName); columnEntity.setAttrname(StringUtils.uncapitalize(attrName)); - + //列的数据类型,转换成Java类型 String attrType = config.getString(columnEntity.getDataType(), "unknowType"); columnEntity.setAttrType(attrType); @@ -100,24 +100,24 @@ public class GenUtils { if("PRI".equalsIgnoreCase(column.get("columnKey")) && tableEntity.getPk() == null){ tableEntity.setPk(columnEntity); } - + columsList.add(columnEntity); } tableEntity.setColumns(columsList); - + //没主键,则第一个字段为主键 if(tableEntity.getPk() == null){ tableEntity.setPk(tableEntity.getColumns().get(0)); } - + //设置velocity资源加载器 - Properties prop = new Properties(); - prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + Properties prop = new Properties(); + prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); Velocity.init(prop); String main = config.getString("main" ); main = StringUtils.isBlank(main) ? config.getString("package" ) : main; - + //封装模板数据 Map map = new HashMap<>(); map.put("tableName", tableEntity.getTableName()); @@ -129,14 +129,7 @@ public class GenUtils { map.put("columns", tableEntity.getColumns()); map.put("hasBigDecimal", hasBigDecimal); map.put("main", main); - - String moduleName = config.getString("moduleName" ); - if(StringUtils.isNotBlank(moduleName)){ - map.put("package", config.getString("package" ) + "." + moduleName); - }else { - map.put("package", config.getString("package" )); - } - + map.put("package", config.getString("package" )); map.put("moduleName", config.getString("moduleName" )); map.put("author", config.getString("author")); map.put("version", config.getString("version")); @@ -146,7 +139,7 @@ public class GenUtils { VelocityContext context = new VelocityContext(map); - + //获取模板列表 List templates = getTemplates(); for(String template : templates){ @@ -154,7 +147,7 @@ public class GenUtils { StringWriter sw = new StringWriter(); Template tpl = Velocity.getTemplate(template, "UTF-8"); tpl.merge(context, sw); - + try { //添加到zip zip.putNextEntry(new ZipEntry(getFileName(template, tableEntity.getClassName(), config.getString("package"), config.getString("moduleName")))); @@ -166,15 +159,15 @@ public class GenUtils { } } } - - + + /** * 列名转换成Java属性名 */ public static String columnToJava(String columnName) { return WordUtils.capitalizeFully(columnName, new char[]{'_'}).replace("_", ""); } - + /** * 表名转换成Java类名 */ @@ -184,7 +177,7 @@ public class GenUtils { } return columnToJava(tableName); } - + /** * 获取配置信息 */ @@ -202,7 +195,7 @@ public class GenUtils { public static String getFileName(String template, String className, String packageName, String moduleName) { String packagePath = "main" + File.separator + "java" + File.separator; if (StringUtils.isNotBlank(packageName)) { - packagePath += packageName.replace(".", File.separator) + File.separator + moduleName + File.separator; + packagePath += packageName.replace(".", File.separator) + File.separator; } if (template.contains("Entity.java.vm" )) { @@ -234,7 +227,7 @@ public class GenUtils { } if (template.contains("DTO.java.vm" )) { - return moduleName + File.separator + "dto" + File.separator + className + "DTO.java"; + return "dto" + File.separator + className + "DTO.java"; } if (template.contains("Dao.xml.vm" )) {