From c9bbdbaa69bd42946fca9d7755c33be8cb8952fc Mon Sep 17 00:00:00 2001 From: Mlxa0324 Date: Tue, 10 Jan 2023 02:26:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_base_design/天泽数据大平台.pdb | 12 +- data_base_design/天泽数据大平台.pdm | 13 +- doc/sql/mysql/tianze-pro-update.sql | 5 +- .../com/ibeetl/jlw/dao/NoticeReadDao.java | 29 +++ .../com/ibeetl/jlw/entity/NoticeRead.java | 126 +++++++++ .../com/ibeetl/jlw/enums/NoticeTypeEnum.java | 21 ++ .../ibeetl/jlw/service/NoticeReadService.java | 185 +++++++++++++ .../ibeetl/jlw/web/NoticeReadController.java | 208 +++++++++++++++ .../ibeetl/jlw/web/query/NoticeReadQuery.java | 121 +++++++++ web/src/main/resources/sql/jlw/noticeRead.md | 245 ++++++++++++++++++ .../resources/static/js/jlw/noticeRead/add.js | 38 +++ .../resources/static/js/jlw/noticeRead/del.js | 23 ++ .../static/js/jlw/noticeRead/edit.js | 28 ++ .../static/js/jlw/noticeRead/index.js | 164 ++++++++++++ .../static/js/jlw/noticeRead/noticeReadApi.js | 18 ++ .../templates/jlw/noticeRead/add.html | 56 ++++ .../templates/jlw/noticeRead/edit.html | 56 ++++ .../templates/jlw/noticeRead/index.html | 29 +++ 18 files changed, 1362 insertions(+), 15 deletions(-) create mode 100644 web/src/main/java/com/ibeetl/jlw/dao/NoticeReadDao.java create mode 100644 web/src/main/java/com/ibeetl/jlw/entity/NoticeRead.java create mode 100644 web/src/main/java/com/ibeetl/jlw/enums/NoticeTypeEnum.java create mode 100644 web/src/main/java/com/ibeetl/jlw/service/NoticeReadService.java create mode 100644 web/src/main/java/com/ibeetl/jlw/web/NoticeReadController.java create mode 100644 web/src/main/java/com/ibeetl/jlw/web/query/NoticeReadQuery.java create mode 100644 web/src/main/resources/sql/jlw/noticeRead.md create mode 100644 web/src/main/resources/static/js/jlw/noticeRead/add.js create mode 100644 web/src/main/resources/static/js/jlw/noticeRead/del.js create mode 100644 web/src/main/resources/static/js/jlw/noticeRead/edit.js create mode 100644 web/src/main/resources/static/js/jlw/noticeRead/index.js create mode 100644 web/src/main/resources/static/js/jlw/noticeRead/noticeReadApi.js create mode 100644 web/src/main/resources/templates/jlw/noticeRead/add.html create mode 100644 web/src/main/resources/templates/jlw/noticeRead/edit.html create mode 100644 web/src/main/resources/templates/jlw/noticeRead/index.html diff --git a/data_base_design/天泽数据大平台.pdb b/data_base_design/天泽数据大平台.pdb index a1e86671..fbf7f90d 100644 --- a/data_base_design/天泽数据大平台.pdb +++ b/data_base_design/天泽数据大平台.pdb @@ -1,5 +1,5 @@ - + @@ -21575,11 +21575,11 @@ COLLATE = utf8_general_ci 2D458A59-6997-4E40-A026-4C8C9CC232EA -teacher_open_course_notice_read -teacher_open_course_notice_read +notice_read +notice_read 1661850632 lx -1673284017 +1673284062 lx 通知公告等-已读时间记录 auto_increment = 1 @@ -21595,11 +21595,11 @@ COLLATE = utf8_general_ci 88D3FAD6-47EF-42D9-89A1-96D2BD3107B1 -teacher_open_course_notice_read_id +notice_read_id notice_read_id 1661850778 lx -1673283995 +1673284062 lx ID bigint diff --git a/data_base_design/天泽数据大平台.pdm b/data_base_design/天泽数据大平台.pdm index fbf7f90d..cc49296f 100644 --- a/data_base_design/天泽数据大平台.pdm +++ b/data_base_design/天泽数据大平台.pdm @@ -1,5 +1,5 @@ - + @@ -21611,11 +21611,11 @@ COLLATE = utf8_general_ci person_id 1662046909 lx -1673283995 +1673287931 lx 人员ID -varchar(2000) -2000 +varchar(100) +100 CF9F793F-60AE-4A22-9114-EAE48E62E95B @@ -21635,11 +21635,10 @@ COLLATE = utf8_general_ci notice_read_time 1662046909 lx -1673283995 +1673287949 lx 已读时间 -varchar(2000) -2000 +datetime D62D3646-4818-463C-98B0-82945D3B4081 diff --git a/doc/sql/mysql/tianze-pro-update.sql b/doc/sql/mysql/tianze-pro-update.sql index 1665736e..41cc08e2 100644 --- a/doc/sql/mysql/tianze-pro-update.sql +++ b/doc/sql/mysql/tianze-pro-update.sql @@ -542,9 +542,9 @@ drop table if exists notice_read; create table notice_read ( notice_read_id bigint not null comment 'ID', - person_id varchar(2000) comment '人员ID', + person_id varchar(100) comment '人员ID', notice_read_type varchar(50) comment '类型 (枚举类 NoticeTypeEnum)', - notice_read_time varchar(2000) comment '已读时间', + notice_read_time datetime comment '已读时间', org_id bigint comment '组织ID', user_id bigint comment '用户ID', primary key (notice_read_id) @@ -555,3 +555,4 @@ create table notice_read COLLATE = utf8_general_ci; alter table notice_read comment '通知公告等-已读时间记录'; + diff --git a/web/src/main/java/com/ibeetl/jlw/dao/NoticeReadDao.java b/web/src/main/java/com/ibeetl/jlw/dao/NoticeReadDao.java new file mode 100644 index 00000000..9efc43eb --- /dev/null +++ b/web/src/main/java/com/ibeetl/jlw/dao/NoticeReadDao.java @@ -0,0 +1,29 @@ +package com.ibeetl.jlw.dao; + +import com.ibeetl.jlw.entity.NoticeRead; +import com.ibeetl.jlw.web.query.NoticeReadQuery; +import org.beetl.sql.core.engine.PageQuery; +import org.beetl.sql.mapper.BaseMapper; +import org.beetl.sql.mapper.annotation.SqlResource; +import org.beetl.sql.mapper.annotation.Update; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 公告已读管理 Dao + */ +// 实际可以不用加Repository注解,调用的地方注入时候,Idea会报红,看着难受 +@Repository +@SqlResource("jlw.noticeRead") +public interface NoticeReadDao extends BaseMapper{ + PageQuery queryByCondition(PageQuery query); + PageQuery queryByConditionQuery(PageQuery query); + @Update + void deleteNoticeReadByIds(String ids); + @Update + int updateGivenByIds(NoticeReadQuery noticeReadQuery); + List getByIds(String ids); + List getValuesByQuery(NoticeReadQuery noticeReadQuery); + List getValuesByQueryNotWithPermission(NoticeReadQuery noticeReadQuery); +} diff --git a/web/src/main/java/com/ibeetl/jlw/entity/NoticeRead.java b/web/src/main/java/com/ibeetl/jlw/entity/NoticeRead.java new file mode 100644 index 00000000..a10f2217 --- /dev/null +++ b/web/src/main/java/com/ibeetl/jlw/entity/NoticeRead.java @@ -0,0 +1,126 @@ +package com.ibeetl.jlw.entity; + +import com.ibeetl.admin.core.entity.BaseEntity; +import com.ibeetl.admin.core.util.ValidateConfig; +import com.ibeetl.jlw.enums.NoticeTypeEnum; +import org.beetl.sql.annotation.entity.AssignID; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/* +* 通知公告等-已读时间记录 +* gen by Spring Boot2 Admin 2023-01-10 +*/ +public class NoticeRead extends BaseEntity{ + + //ID + @NotNull(message = "ID不能为空", groups =ValidateConfig.UPDATE.class) + // @SeqID(name = ORACLE_CORE_SEQ_NAME) + @AssignID(value = "maskAutoID",param = "com.ibeetl.jlw.entity.NoticeRead") + + private Long noticeReadId ; + + //人员ID + + private String personId ; + + //类型 (枚举类 NoticeTypeEnum) + + private NoticeTypeEnum noticeReadType ; + + //已读时间 + + private Date noticeReadTime ; + + //组织ID + + private Long orgId ; + + //用户ID + + private Long userId ; + + public NoticeRead(){ + } + + /**ID + *@return + */ + public Long getNoticeReadId(){ + return noticeReadId; + } + /**ID + *@param noticeReadId + */ + public void setNoticeReadId(Long noticeReadId){ + this.noticeReadId = noticeReadId; + } + + /**人员ID + *@return + */ + public String getPersonId(){ + return personId; + } + /**人员ID + *@param personId + */ + public void setPersonId(String personId){ + this.personId = personId; + } + + /**类型 (枚举类 NoticeTypeEnum) + *@return + */ + public NoticeTypeEnum getNoticeReadType(){ + return noticeReadType; + } + /**类型 (枚举类 NoticeTypeEnum) + *@param noticeReadType + */ + public void setNoticeReadType(NoticeTypeEnum noticeReadType){ + this.noticeReadType = noticeReadType; + } + + /**已读时间 + *@return + */ + public Date getNoticeReadTime(){ + return noticeReadTime; + } + /**已读时间 + *@param noticeReadTime + */ + public void setNoticeReadTime(Date noticeReadTime){ + this.noticeReadTime = noticeReadTime; + } + + /**组织ID + *@return + */ + public Long getOrgId(){ + return orgId; + } + /**组织ID + *@param orgId + */ + public void setOrgId(Long orgId){ + this.orgId = orgId; + } + + /**用户ID + *@return + */ + public Long getUserId(){ + return userId; + } + /**用户ID + *@param userId + */ + public void setUserId(Long userId){ + this.userId = userId; + } + + +} diff --git a/web/src/main/java/com/ibeetl/jlw/enums/NoticeTypeEnum.java b/web/src/main/java/com/ibeetl/jlw/enums/NoticeTypeEnum.java new file mode 100644 index 00000000..c6f84ca4 --- /dev/null +++ b/web/src/main/java/com/ibeetl/jlw/enums/NoticeTypeEnum.java @@ -0,0 +1,21 @@ +package com.ibeetl.jlw.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.beetl.sql.annotation.entity.EnumMapping; + +/** + * notice_read 表的类型 + * 用于记录通知相关的已读 + * + * @author mlx + */ +@Getter +@EnumMapping("name") +@AllArgsConstructor +public enum NoticeTypeEnum { + + OPEN_COURSE_NOTICE("开课通知公告"); + + private String text; +} diff --git a/web/src/main/java/com/ibeetl/jlw/service/NoticeReadService.java b/web/src/main/java/com/ibeetl/jlw/service/NoticeReadService.java new file mode 100644 index 00000000..96844e12 --- /dev/null +++ b/web/src/main/java/com/ibeetl/jlw/service/NoticeReadService.java @@ -0,0 +1,185 @@ +package com.ibeetl.jlw.service; + +import cn.hutool.core.collection.CollectionUtil; +import cn.jlw.util.ToolUtils; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ibeetl.admin.core.entity.CoreUser; +import com.ibeetl.admin.core.service.CoreBaseService; +import com.ibeetl.admin.core.util.PlatformException; +import com.ibeetl.admin.core.web.JsonResult; +import com.ibeetl.admin.core.web.JsonReturnCode; +import com.ibeetl.jlw.dao.NoticeReadDao; +import com.ibeetl.jlw.entity.NoticeRead; +import com.ibeetl.jlw.enums.NoticeTypeEnum; +import com.ibeetl.jlw.web.query.NoticeReadQuery; +import org.apache.commons.lang3.StringUtils; +import org.beetl.sql.core.SqlId; +import org.beetl.sql.core.engine.PageQuery; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * 公告已读管理 Service + * 当分布式ID开启后请勿使用insert(*,true) + */ + +@Service +@Transactional +@Validated +public class NoticeReadService extends CoreBaseService{ + + @Autowired private NoticeReadDao noticeReadDao; + + public PageQueryqueryByCondition(PageQuery query){ + PageQuery ret = noticeReadDao.queryByCondition(query); + queryListAfter(ret.getList()); + return ret; + } + + public PageQueryqueryByConditionQuery(PageQuery query){ + PageQuery ret = noticeReadDao.queryByConditionQuery(query); + queryListAfter(ret.getList()); + return ret; + } + + public void deleteByList(List list){ + String ids = ""; + ToolUtils.deleteNullList(list); + for(int i=0;null != list && i noticeReadList = new ArrayList<>(); + try { + noticeReadList = JSON.parseArray(noticeReadQuery.getNoticeReadJsonStr(), NoticeRead.class); + } catch (Exception e) { + try { + noticeReadList.add(JSONObject.parseObject(noticeReadQuery.getNoticeReadJsonStr(), NoticeRead.class)); + } catch (Exception e1) {} + } + ToolUtils.deleteNullList(noticeReadList); + if(null != noticeReadList && noticeReadList.size()>0){ + for(int i=0;i 0; + if(!flag){ + msg = "更新指定参数失败"; + } + }else{ + msg = "指定参数为空"; + } + return msg; + } + + public List getValues (Object paras){ + return sqlManager.select(SqlId.of("jlw.noticeRead.getNoticeReadValues"), NoticeRead.class, paras); + } + + public List getValuesByQuery (NoticeReadQuery noticeReadQuery){ + return noticeReadDao.getValuesByQuery(noticeReadQuery); + } + + public List getValuesByQueryNotWithPermission (NoticeReadQuery noticeReadQuery){ + return noticeReadDao.getValuesByQueryNotWithPermission(noticeReadQuery); + } + + public NoticeRead getInfo (Long noticeReadId){ + NoticeReadQuery noticeReadQuery = new NoticeReadQuery(); + noticeReadQuery.setNoticeReadId(noticeReadId); + List list = noticeReadDao.getValuesByQuery(noticeReadQuery); + if(null != list && list.size()>0){ + return list.get(0); + }else{ + return null; + } + } + + public NoticeRead getInfo (NoticeReadQuery noticeReadQuery){ + List list = noticeReadDao.getValuesByQuery(noticeReadQuery); + if(null != list && list.size()>0){ + return list.get(0); + }else{ + return null; + } + } + + /** + * 已读 + * @param coreUser + * @return + */ + public void readed(@NotNull(message = "查询的公告类型不能为空!") NoticeTypeEnum noticeType, @NotNull(message = "用户未登录!") CoreUser coreUser) { + NoticeReadQuery noticeReadQuery = new NoticeReadQuery(); + noticeReadQuery.setPersonId(coreUser.getId().toString()); + noticeReadQuery.setNoticeReadType(noticeType); + List list = noticeReadDao.getValuesByQueryNotWithPermission(noticeReadQuery); + + // 更新已读的时间点 + if (CollectionUtil.isNotEmpty(list)) { + NoticeRead noticeRead = list.get(0); + noticeRead.setNoticeReadTime(new Date()); + updateTemplate(noticeRead); + } + else { + NoticeRead insertPO = new NoticeRead(); + insertPO.setNoticeReadTime(new Date()); + insertPO.setNoticeReadType(noticeType); + insertPO.setUserId(coreUser.getId()); + insertPO.setOrgId(coreUser.getOrgId()); + insertPO.setPersonId(coreUser.getId().toString()); + insert(insertPO); + } + } +} diff --git a/web/src/main/java/com/ibeetl/jlw/web/NoticeReadController.java b/web/src/main/java/com/ibeetl/jlw/web/NoticeReadController.java new file mode 100644 index 00000000..ea161d64 --- /dev/null +++ b/web/src/main/java/com/ibeetl/jlw/web/NoticeReadController.java @@ -0,0 +1,208 @@ +package com.ibeetl.jlw.web; + +import cn.hutool.core.lang.Assert; +import cn.jlw.Interceptor.SCoreUser; +import cn.jlw.validate.ValidateConfig; +import com.ibeetl.admin.core.annotation.Function; +import com.ibeetl.admin.core.entity.CoreUser; +import com.ibeetl.admin.core.file.FileService; +import com.ibeetl.admin.core.web.JsonResult; +import com.ibeetl.jlw.entity.NoticeRead; +import com.ibeetl.jlw.enums.NoticeTypeEnum; +import com.ibeetl.jlw.service.NoticeReadService; +import com.ibeetl.jlw.web.query.NoticeReadQuery; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.beetl.sql.core.engine.PageQuery; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.BindingResult; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +import java.util.List; + +import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser; + +/** + * 公告已读管理 通知公告等-已读时间记录 接口 + * 切记不要对非线程安全的静态变量进行写操作 + */ + +@RestController +@Validated +public class NoticeReadController{ + + private final Log log = LogFactory.getLog(this.getClass()); + private static final String MODEL = "/jlw/noticeRead"; + private static final String API = "/api/noticeRead"; + + + @Autowired private NoticeReadService noticeReadService; + + @Autowired FileService fileService; + + /* 前端接口 */ + + @PostMapping(API + "/getPageList.do") + public JsonResult getPageList(NoticeReadQuery condition,@SCoreUser CoreUser coreUser){ + if(null == coreUser){ + return JsonResult.failMessage("请登录后再操作"); + }else{ + PageQuery page = condition.getPageQuery(); + noticeReadService.queryByConditionQuery(page); + return JsonResult.success(page); + } + } + + + @GetMapping(API + "/getInfo.do") + public JsonResultgetInfo(NoticeReadQuery param,@SCoreUser CoreUser coreUser) { + if(null == coreUser){ + return JsonResult.failMessage("请登录后再操作"); + }else{ + NoticeRead noticeRead = noticeReadService.getInfo(param); + return JsonResult.success(noticeRead); + } + } + + + @GetMapping(API + "/getList.do") + public JsonResult>getList(NoticeReadQuery param,@SCoreUser CoreUser coreUser) { + if(null == coreUser){ + return JsonResult.failMessage("请登录后再操作"); + }else{ + Listlist = noticeReadService.getValuesByQuery(param); + return JsonResult.success(list); + } + } + + + /* 后台页面 */ + + @GetMapping(MODEL + "/index.do") + public ModelAndView index() { + ModelAndView view = new ModelAndView("/jlw/noticeRead/index.html") ; + view.addObject("search", NoticeReadQuery.class.getName()); + return view; + } + + @GetMapping(MODEL + "/edit.do") + public ModelAndView edit(Long noticeReadId) { + ModelAndView view = new ModelAndView("/jlw/noticeRead/edit.html"); + NoticeRead noticeRead = noticeReadService.queryById(noticeReadId); + view.addObject("noticeRead", noticeRead); + return view; + } + + @GetMapping(MODEL + "/add.do") + public ModelAndView add(Long noticeReadId) { + ModelAndView view = new ModelAndView("/jlw/noticeRead/add.html"); + if(null != noticeReadId){ + NoticeRead noticeRead = noticeReadService.queryById(noticeReadId); + view.addObject("noticeRead", noticeRead); + }else { + view.addObject("noticeRead", new NoticeRead()); + } + return view; + } + + /* 后台接口 */ + + @PostMapping(MODEL + "/list.json") + public JsonResult list(NoticeReadQuery condition){ + PageQuery page = condition.getPageQuery(); + noticeReadService.queryByCondition(page); + return JsonResult.success(page); + } + + @PostMapping(MODEL + "/addAll.json") + public JsonResult addAll(NoticeReadQuery noticeReadQuery,@SCoreUser CoreUser coreUser){ + if(null == coreUser){ + return JsonResult.failMessage("请登录后再操作"); + }else{ + noticeReadQuery.setUserId(coreUser.getId()); + noticeReadQuery.setOrgId(coreUser.getOrgId()); + String msg = noticeReadService.addAll(noticeReadQuery); + if (StringUtils.isBlank(msg)) { + return JsonResult.success(); + } else { + return JsonResult.failMessage("新增失败,"+msg); + } + } + } + + @PostMapping(MODEL + "/add.json") + public JsonResult add(@Validated(ValidateConfig.ADD.class) NoticeReadQuery noticeReadQuery, BindingResult result,@SCoreUser CoreUser coreUser){ + if(result.hasErrors()){ + return JsonResult.failMessage(result); + }else{ + + noticeReadQuery.setUserId(coreUser.getId()); + noticeReadQuery.setOrgId(coreUser.getOrgId()); + return noticeReadService.add(noticeReadQuery); + } + } + + @PostMapping(MODEL + "/edit.json") + public JsonResult update(@Validated(ValidateConfig.UPDATE.class) NoticeReadQuery noticeReadQuery, BindingResult result) { + if(result.hasErrors()){ + return JsonResult.failMessage(result); + }else { + Assert.notNull(getUser(), "请登录后再操作"); + noticeReadQuery.setUserId(null); + noticeReadQuery.setOrgId(null); + String msg = noticeReadService.edit(noticeReadQuery); + if (StringUtils.isBlank(msg)) { + return JsonResult.success(); + } else { + return JsonResult.failMessage("更新失败,"+msg); + } + } + } + + + @GetMapping(MODEL + "/view.json") + @Function("noticeRead.query") + public JsonResultqueryInfo(Long noticeReadId) { + NoticeRead noticeRead = noticeReadService.queryById( noticeReadId); + return JsonResult.success(noticeRead); + } + + @GetMapping(MODEL + "/getValues.json") + public JsonResult>getValues(NoticeReadQuery param) { + Listlist = noticeReadService.getValuesByQuery(param); + return JsonResult.success(list); + } + + + @PostMapping(MODEL + "/delete.json") + @ResponseBody + public JsonResult delete(String ids) { + noticeReadService.deleteNoticeRead(ids); + return JsonResult.success(); + } + + /** + * 功能描述:
+ * 通知已读, 也可以用于教师讨论的已读 + * + * @param noticeType 通知类型 + * @param coreUser + * @return {@link JsonResult} + * @Author: lx + * @Date: 2023/1/10 2:23 + */ + @PostMapping(MODEL + "/readed.json") + @ResponseBody + public JsonResult readed(NoticeTypeEnum noticeType, @SCoreUser CoreUser coreUser) { + noticeReadService.readed(noticeType, coreUser); + return JsonResult.success(); + } + + +} diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/NoticeReadQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/NoticeReadQuery.java new file mode 100644 index 00000000..ae196bb4 --- /dev/null +++ b/web/src/main/java/com/ibeetl/jlw/web/query/NoticeReadQuery.java @@ -0,0 +1,121 @@ +package com.ibeetl.jlw.web.query; + +import cn.jlw.validate.ValidateConfig; +import com.ibeetl.admin.core.annotation.Query; +import com.ibeetl.admin.core.entity.CoreUser; +import com.ibeetl.admin.core.web.query.PageParam; +import com.ibeetl.jlw.entity.NoticeRead; +import com.ibeetl.jlw.enums.NoticeTypeEnum; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + *公告已读管理查询 + */ +public class NoticeReadQuery extends PageParam { + @NotNull(message = "ID不能为空", groups =ValidateConfig.UPDATE.class) + @Query(name = "ID", display = false) + private Long noticeReadId; + /** + * 保存的是系统用户ID + * {@link CoreUser#getId()} + */ + @Query(name = "人员ID", display = false) + private String personId; + @Query(name = "类型 (枚举类 NoticeTypeEnum)", display = false) + private NoticeTypeEnum noticeReadType; + @Query(name = "已读时间", display = false) + private Date noticeReadTime; + @Query(name = "组织ID", display = false) + private Long orgId; + @Query(name = "用户ID", display = false) + private Long userId; + + private String noticeReadIdPlural; + private String orgIdPlural; + private String userIdPlural; + + private String noticeReadJsonStr;//json格式 + + private String _given;//指定更新的特定字段,多个逗号隔开 + + public Long getNoticeReadId(){ + return noticeReadId; + } + public void setNoticeReadId(Long noticeReadId ){ + this.noticeReadId = noticeReadId; + } + public String getPersonId(){ + return personId; + } + public void setPersonId(String personId ){ + this.personId = personId; + } + public NoticeTypeEnum getNoticeReadType(){ + return noticeReadType; + } + public void setNoticeReadType(NoticeTypeEnum noticeReadType ){ + this.noticeReadType = noticeReadType; + } + public Date getNoticeReadTime(){ + return noticeReadTime; + } + public void setNoticeReadTime(Date noticeReadTime ){ + this.noticeReadTime = noticeReadTime; + } + public Long getOrgId(){ + return orgId; + } + public void setOrgId(Long orgId ){ + this.orgId = orgId; + } + public Long getUserId(){ + return userId; + } + public void setUserId(Long userId ){ + this.userId = userId; + } + + public NoticeRead pojo(){ + NoticeRead pojo = new NoticeRead(); + pojo.setNoticeReadId(this.getNoticeReadId()); + pojo.setPersonId(this.getPersonId()); + pojo.setNoticeReadType(this.getNoticeReadType()); + pojo.setNoticeReadTime(this.getNoticeReadTime()); + pojo.setOrgId(this.getOrgId()); + pojo.setUserId(this.getUserId()); + return pojo; + } + + public String getNoticeReadIdPlural(){ + return noticeReadIdPlural; + } + public void setNoticeReadIdPlural(String noticeReadIdPlural){ + this.noticeReadIdPlural = noticeReadIdPlural; + } + public String getOrgIdPlural(){ + return orgIdPlural; + } + public void setOrgIdPlural(String orgIdPlural){ + this.orgIdPlural = orgIdPlural; + } + public String getUserIdPlural(){ + return userIdPlural; + } + public void setUserIdPlural(String userIdPlural){ + this.userIdPlural = userIdPlural; + } + public String getNoticeReadJsonStr(){ + return noticeReadJsonStr; + } + public void setNoticeReadJsonStr(String noticeReadJsonStr ){ + this.noticeReadJsonStr = noticeReadJsonStr; + } + public String get_given() { + return _given; + } + public void set_given(String _given) { + this._given = _given; + } +} diff --git a/web/src/main/resources/sql/jlw/noticeRead.md b/web/src/main/resources/sql/jlw/noticeRead.md new file mode 100644 index 00000000..19b0d4aa --- /dev/null +++ b/web/src/main/resources/sql/jlw/noticeRead.md @@ -0,0 +1,245 @@ +queryByCondition +=== +* 根据不为空的参数进行分页查询 + + select + @pageTag(){ + t.* + @} + from notice_read t + where 1=1 + @if(!isEmpty(noticeReadId)){ + and t.notice_read_id =#noticeReadId# + @} + @if(!isEmpty(noticeReadIdPlural)){ + and find_in_set(t.notice_read_id,#noticeReadIdPlural#) + @} + @if(!isEmpty(personId)){ + and t.person_id =#personId# + @} + @if(!isEmpty(noticeReadType)){ + and t.notice_read_type =#noticeReadType# + @} + @if(!isEmpty(noticeReadTime)){ + and t.notice_read_time =#noticeReadTime# + @} + @if(!isEmpty(orgId)){ + and t.org_id =#orgId# + @} + @if(!isEmpty(orgIdPlural)){ + and find_in_set(t.org_id,#orgIdPlural#) + @} + @if(!isEmpty(userId)){ + and t.user_id =#userId# + @} + @if(!isEmpty(userIdPlural)){ + and find_in_set(t.user_id,#userIdPlural#) + @} + + +queryByConditionQuery +=== +* 根据不为空的参数进行分页查询(无权限) + + select + @pageTag(){ + t.* + @} + from notice_read t + where 1=1 + @if(!isEmpty(noticeReadId)){ + and t.notice_read_id =#noticeReadId# + @} + @if(!isEmpty(noticeReadIdPlural)){ + and find_in_set(t.notice_read_id,#noticeReadIdPlural#) + @} + @if(!isEmpty(personId)){ + and t.person_id =#personId# + @} + @if(!isEmpty(noticeReadType)){ + and t.notice_read_type =#noticeReadType# + @} + @if(!isEmpty(noticeReadTime)){ + and t.notice_read_time =#noticeReadTime# + @} + @if(!isEmpty(orgId)){ + and t.org_id =#orgId# + @} + @if(!isEmpty(orgIdPlural)){ + and find_in_set(t.org_id,#orgIdPlural#) + @} + @if(!isEmpty(userId)){ + and t.user_id =#userId# + @} + @if(!isEmpty(userIdPlural)){ + and find_in_set(t.user_id,#userIdPlural#) + @} + + + + +deleteNoticeReadByIds +=== + +* 批量删除 + + delete from notice_read where find_in_set(notice_read_id,#ids#) + + + +getByIds +=== + +select * from notice_read where find_in_set(notice_read_id,#ids#) + + +updateGivenByIds +=== + +* 批量更新指定字段,无论此字段是否有值 + + update notice_read + set + @if(contain("personId",_given)){ + @if(isEmpty(personId)){ + person_id = null , + @}else{ + person_id = #personId# , + @} + @} + @if(contain("noticeReadType",_given)){ + @if(isEmpty(noticeReadType)){ + notice_read_type = null , + @}else{ + notice_read_type = #noticeReadType# , + @} + @} + @if(contain("noticeReadTime",_given)){ + @if(isEmpty(noticeReadTime)){ + notice_read_time = null , + @}else{ + notice_read_time = #noticeReadTime# , + @} + @} + @if(contain("orgId",_given)){ + @if(isEmpty(orgId)){ + org_id = null , + @}else{ + org_id = #orgId# , + @} + @} + @if(contain("userId",_given)){ + @if(isEmpty(userId)){ + user_id = null , + @}else{ + user_id = #userId# , + @} + @} + notice_read_id = notice_read_id + where find_in_set(notice_read_id,#noticeReadIdPlural#) + + + +getNoticeReadValues +=== + +* 根据不为空的参数进行查询 + + select t.* + from notice_read t + where 1=1 + @if(!isEmpty(noticeReadId)){ + and t.notice_read_id =#noticeReadId# + @} + @if(!isEmpty(personId)){ + and t.person_id =#personId# + @} + @if(!isEmpty(noticeReadType)){ + and t.notice_read_type =#noticeReadType# + @} + @if(!isEmpty(noticeReadTime)){ + and t.notice_read_time =#noticeReadTime# + @} + @if(!isEmpty(orgId)){ + and t.org_id =#orgId# + @} + @if(!isEmpty(userId)){ + and t.user_id =#userId# + @} + + +getValuesByQuery +=== + +* 根据不为空的参数进行查询 + + select t.* + from notice_read t + where 1=1 + @if(!isEmpty(noticeReadId)){ + and t.notice_read_id =#noticeReadId# + @} + @if(!isEmpty(noticeReadIdPlural)){ + and find_in_set(t.notice_read_id,#noticeReadIdPlural#) + @} + @if(!isEmpty(personId)){ + and t.person_id =#personId# + @} + @if(!isEmpty(noticeReadType)){ + and t.notice_read_type =#noticeReadType# + @} + @if(!isEmpty(noticeReadTime)){ + and t.notice_read_time =#noticeReadTime# + @} + @if(!isEmpty(orgId)){ + and t.org_id =#orgId# + @} + @if(!isEmpty(orgIdPlural)){ + and find_in_set(t.org_id,#orgIdPlural#) + @} + @if(!isEmpty(userId)){ + and t.user_id =#userId# + @} + @if(!isEmpty(userIdPlural)){ + and find_in_set(t.user_id,#userIdPlural#) + @} + + +getValuesByQueryNotWithPermission +=== + +* 根据不为空的参数进行查询(不包含权限) + + select t.* + from notice_read t + where 1=1 + @if(!isEmpty(noticeReadId)){ + and t.notice_read_id =#noticeReadId# + @} + @if(!isEmpty(noticeReadIdPlural)){ + and find_in_set(t.notice_read_id,#noticeReadIdPlural#) + @} + @if(!isEmpty(personId)){ + and t.person_id =#personId# + @} + @if(!isEmpty(noticeReadType)){ + and t.notice_read_type =#noticeReadType# + @} + @if(!isEmpty(noticeReadTime)){ + and t.notice_read_time =#noticeReadTime# + @} + @if(!isEmpty(orgId)){ + and t.org_id =#orgId# + @} + @if(!isEmpty(orgIdPlural)){ + and find_in_set(t.org_id,#orgIdPlural#) + @} + @if(!isEmpty(userId)){ + and t.user_id =#userId# + @} + @if(!isEmpty(userIdPlural)){ + and find_in_set(t.user_id,#userIdPlural#) + @} + + + diff --git a/web/src/main/resources/static/js/jlw/noticeRead/add.js b/web/src/main/resources/static/js/jlw/noticeRead/add.js new file mode 100644 index 00000000..5eb7ad08 --- /dev/null +++ b/web/src/main/resources/static/js/jlw/noticeRead/add.js @@ -0,0 +1,38 @@ +layui.define([ 'form', 'laydate', 'table','noticeReadApi'], function(exports) { + var form = layui.form; + var noticeReadApi = layui.noticeReadApi; + var index = layui.index; + var view = { + init:function(){ + Lib.initGenrealForm($("#addForm"),form); + this.initSubmit(); + }, + initSubmit:function(){ + $("#addButton").click(function(){ + form.on('submit(form)', function(){ + var noticeReadId = $("#addForm input[name='noticeReadId']").val(); + if(!$.isEmpty(noticeReadId)){ + noticeReadApi.updateNoticeRead($('#addForm'),function(){ + parent.window.dataReload(); + Common.info("更新成功"); + Lib.closeFrame(); + }); + }else{ + noticeReadApi.addNoticeRead($('#addForm'),function(){ + parent.window.dataReload(); + Common.info("添加成功"); + Lib.closeFrame(); + }); + } + + }); + }); + + $("#addButton-cancel").click(function(){ + Lib.closeFrame(); + }); + } + + } + exports('add',view); +}); diff --git a/web/src/main/resources/static/js/jlw/noticeRead/del.js b/web/src/main/resources/static/js/jlw/noticeRead/del.js new file mode 100644 index 00000000..70a542fe --- /dev/null +++ b/web/src/main/resources/static/js/jlw/noticeRead/del.js @@ -0,0 +1,23 @@ +layui.define(['table', 'noticeReadApi'], function(exports) { + var noticeReadApi = layui.noticeReadApi; + var table=layui.table; + var view = { + init:function(){ + }, + delBatch:function(){ + var data = Common.getMoreDataFromTable(table,"noticeReadTable"); + if(data==null){ + return ; + } + Common.openConfirm("确认要删除这些公告已读管理?",function(){ + var ids =Common.concatBatchId(data,"noticeReadId"); + noticeReadApi.del(ids,function(){ + Common.info("删除成功"); + dataReload(); + }) + }) + } + } + exports('del',view); + +}); \ No newline at end of file diff --git a/web/src/main/resources/static/js/jlw/noticeRead/edit.js b/web/src/main/resources/static/js/jlw/noticeRead/edit.js new file mode 100644 index 00000000..46aba202 --- /dev/null +++ b/web/src/main/resources/static/js/jlw/noticeRead/edit.js @@ -0,0 +1,28 @@ +layui.define([ 'form', 'laydate', 'table','noticeReadApi'], function(exports) { + var form = layui.form; + var noticeReadApi = layui.noticeReadApi; + var index = layui.index; + var view = { + init:function(){ + Lib.initGenrealForm($("#updateForm"),form); + this.initSubmit(); + }, + initSubmit:function(){ + $("#updateButton").click(function(){ + form.on('submit(form)', function(){ + noticeReadApi.updateNoticeRead($('#updateForm'),function(){ + parent.window.dataReload(); + Common.info("更新成功"); + Lib.closeFrame(); + }); + }); + }); + $("#updateButton-cancel").click(function(){ + Lib.closeFrame(); + }); + } + + } + exports('edit',view); + +}); \ No newline at end of file diff --git a/web/src/main/resources/static/js/jlw/noticeRead/index.js b/web/src/main/resources/static/js/jlw/noticeRead/index.js new file mode 100644 index 00000000..4fa55d7c --- /dev/null +++ b/web/src/main/resources/static/js/jlw/noticeRead/index.js @@ -0,0 +1,164 @@ +layui.define([ 'form', 'laydate', 'table' ], function(exports) { + var form = layui.form; + var laydate = layui.laydate; + var table = layui.table; + var noticeReadTable = null; + var view ={ + init:function(){ + var that = this + this.initTable(); + this.initSearchForm(); + this.initToolBar(); + window.dataReload = function(){ + Lib.doSearchForm($("#searchForm"),noticeReadTable) + that.initToolBar(); + } + }, + initTable:function(){ + var sx_ = localStorage.getItem("noticeReadTable_field_"+Common.userInfoId); //筛选值显示、隐藏缓存 + if($.isEmpty(sx_)){sx_ = {};}else {sx_ = JSON.parse(sx_);} + noticeReadTable = table.render({ + elem : '#noticeReadTable', + height : Lib.getTableHeight(1), + cellMinWidth: 100, + method : 'post', + url : Common.ctxPath + '/jlw/noticeRead/list.json' // 数据接口 + ,page : Lib.tablePage // 开启分页 + ,toolbar: '#toolbar_noticeRead' //自定义头部左侧工具栏 + ,defaultToolbar: ['filter', 'print', 'exports'] //头部右侧工具栏 + ,limit : 10, + cols : [ [ // 表头 + { + type : 'checkbox', + + }, + { + field : 'noticeReadId', + title : 'ID', + align:"center", + hideField :false, + hide:$.isEmpty(sx_['noticeReadId'])?false:sx_['noticeReadId'], + + width : 60, + }, + { + field : 'personId', + title : '人员ID', + align:"center", + hideField :false, + hide:$.isEmpty(sx_['personId'])?false:sx_['personId'], + }, + { + field : 'noticeReadType', + title : '类型 (枚举类 NoticeTypeEnum)', + align:"center", + hideField :false, + hide:$.isEmpty(sx_['noticeReadType'])?false:sx_['noticeReadType'], + }, + { + field : 'noticeReadTime', + title : '已读时间', + align:"center", + hideField :false, + hide:$.isEmpty(sx_['noticeReadTime'])?false:sx_['noticeReadTime'], + }, + { + field : 'orgId', + title : '组织ID', + align:"center", + hideField :false, + hide:$.isEmpty(sx_['orgId'])?false:sx_['orgId'], + }, + { + field : 'userId', + title : '用户ID', + align:"center", + hideField :false, + hide:$.isEmpty(sx_['userId'])?false:sx_['userId'], + } + ,{ + field : 'operation_',title : '操作',align:"center", templet: function (d) { + var htm = ''; + htm += ''; + return htm; + } + } + + ] ] + + }); + + table.on('checkbox(noticeReadTable)', function(obj){ + var noticeRead = obj.data; + if(obj.checked){ + //按钮逻辑Lib.buttonEnable() + }else{ + + } + }) + }, + + initSearchForm:function(){ + Lib.initSearchForm( $("#searchForm"),noticeReadTable,form); + }, + + initToolBar:function(){ + toolbar = { + add: function () { + var url = "/jlw/noticeRead/add.do"; + Common.openDlg(url,"公告已读管理管理>新增"); + }, + edit: function () { + var data = Common.getOneFromTable(table,"noticeReadTable"); + if(data==null){ + return ; + } + var url = "/jlw/noticeRead/add.do?noticeReadId="+data.noticeReadId; + Common.openDlg(url,"公告已读管理管理>"+data.noticeReadId+">编辑"); + }, + del: function () { + layui.use(['del'], function(){ + var delView = layui.del + delView.delBatch(); + }); + }, + search: function () { + Lib.doSearchForm($("#searchForm"), noticeReadTable, 1); + view.initToolBar() + }, + refresh: function () { + searchForm.reset(); + Lib.doSearchForm($("#searchForm"), noticeReadTable, 1); + view.initToolBar() + }, + } + //触发事件 + $('.ext-toolbar').on('click', function() { + var type = $(this).data('type'); + toolbar[type] ? toolbar[type].call(this) : ''; + }); + + }, initTableTool: table.on('tool(noticeReadTable)', function (obj) { + var data = obj.data; + if (obj.event === 'edit') { + var url = "/jlw/noticeRead/add.do?noticeReadId="+data.noticeReadId; + Common.openDlg(url,"公告已读管理管理>"+data.noticeReadId+">编辑"); + }else if(obj.event === "del"){ + layer.confirm('是否确定删除该信息?', function (index) { + var ret = Common.postAjax("/jlw/noticeRead/delete.json",{ids:data.noticeReadId}); + layer.msg(ret.code == 0?"删除成功!":ret.msg, { + offset: ['50%'], + icon: ret.code == 0?1:2, + time: 1500 //2秒关闭(如果不配置,默认是3秒) + },function (){ + if(ret.code == 0){ + Lib.tableRefresh(); + } + }); + }); + } + }) + } + exports('index',view); + +}); diff --git a/web/src/main/resources/static/js/jlw/noticeRead/noticeReadApi.js b/web/src/main/resources/static/js/jlw/noticeRead/noticeReadApi.js new file mode 100644 index 00000000..1802107d --- /dev/null +++ b/web/src/main/resources/static/js/jlw/noticeRead/noticeReadApi.js @@ -0,0 +1,18 @@ +/*访问后台的代码*/ +layui.define([], function(exports) { + var api={ + updateNoticeRead:function(form,callback){ + Lib.submitForm("/jlw/noticeRead/edit.json",form,{},callback) + }, + addNoticeRead:function(form,callback){ + Lib.submitForm("/jlw/noticeRead/add.json",form,{},callback) + }, + del:function(ids,callback){ + Common.post("/jlw/noticeRead/delete.json",{"ids":ids},function(){ + callback(); + }) + } + + }; + exports('noticeReadApi',api); +}); \ No newline at end of file diff --git a/web/src/main/resources/templates/jlw/noticeRead/add.html b/web/src/main/resources/templates/jlw/noticeRead/add.html new file mode 100644 index 00000000..2affe8ac --- /dev/null +++ b/web/src/main/resources/templates/jlw/noticeRead/add.html @@ -0,0 +1,56 @@ + + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+ + + + + + diff --git a/web/src/main/resources/templates/jlw/noticeRead/edit.html b/web/src/main/resources/templates/jlw/noticeRead/edit.html new file mode 100644 index 00000000..befdd124 --- /dev/null +++ b/web/src/main/resources/templates/jlw/noticeRead/edit.html @@ -0,0 +1,56 @@ + + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+ + + + + + diff --git a/web/src/main/resources/templates/jlw/noticeRead/index.html b/web/src/main/resources/templates/jlw/noticeRead/index.html new file mode 100644 index 00000000..e06b3a66 --- /dev/null +++ b/web/src/main/resources/templates/jlw/noticeRead/index.html @@ -0,0 +1,29 @@ + + + +
+ + + +