Browse Source

添加 消息相关

dev_shibei_match
zhaoqifeng 6 years ago
parent
commit
daa0689f26
  1. 3
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/FieldConstant.java
  2. 107
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/UserMessageDTO.java
  3. 94
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/UserMessageController.java
  4. 39
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/UserMessageDao.java
  5. 73
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/UserMessageEntity.java
  6. 77
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/UserMessageExcel.java
  7. 47
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/UserMessageRedis.java
  8. 104
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/UserMessageService.java
  9. 116
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/UserMessageServiceImpl.java
  10. 27
      epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/UserMessageDao.xml

3
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/FieldConstant.java

@ -49,6 +49,7 @@ public interface FieldConstant {
String GRID_ID = "GRID_ID";
String GRID_ID_HUMP = "gridId";
String USER_ID = "USER_ID";
String USER_ID_HUMP = "userId";
}

107
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/UserMessageDTO.java

@ -0,0 +1,107 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 用户消息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-07
*/
@Data
public class UserMessageDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 客户id
*/
private String customerId;
/**
* app=resi时此列为gridId,其他情况暂定 *
*/
private String gridId;
/**
* 对应用户id
*/
private String userId;
/**
* 消息通知对象居民端用户resi政府端工作人员gov运营端工作人员oper
*/
private String app;
/**
* 消息标题
*/
private String title;
/**
* 消息通知内容
*/
private String messageContent;
/**
* read已读unread未读
*/
private String readFlag;
/**
* 删除标记 0未删除1已删除
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人(发布消息的人)
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

94
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/UserMessageController.java

@ -0,0 +1,94 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.controller;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.dto.UserMessageDTO;
import com.epmet.excel.UserMessageExcel;
import com.epmet.service.UserMessageService;
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 generator generator@elink-cn.com
* @since v1.0.0 2020-04-07
*/
@RestController
@RequestMapping("usermessage")
public class UserMessageController {
@Autowired
private UserMessageService userMessageService;
@GetMapping("page")
public Result<PageData<UserMessageDTO>> page(@RequestParam Map<String, Object> params){
PageData<UserMessageDTO> page = userMessageService.page(params);
return new Result<PageData<UserMessageDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<UserMessageDTO> get(@PathVariable("id") String id){
UserMessageDTO data = userMessageService.get(id);
return new Result<UserMessageDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody UserMessageDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
userMessageService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody UserMessageDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
userMessageService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
userMessageService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<UserMessageDTO> list = userMessageService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, UserMessageExcel.class);
}
}

39
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/UserMessageDao.java

@ -0,0 +1,39 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.UserMessageEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 用户消息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-07
*/
@Mapper
public interface UserMessageDao extends BaseDao<UserMessageEntity> {
/**
* 更新阅读状态为已读
*
* @param entity 参数
*/
void updateReadFlag(UserMessageEntity entity);
}

73
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/UserMessageEntity.java

@ -0,0 +1,73 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 用户消息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-07
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("user_message")
public class UserMessageEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户id
*/
private String customerId;
/**
* app=resi时此列为gridId,其他情况暂定 *
*/
private String gridId;
/**
* 对应用户id
*/
private String userId;
/**
* 消息通知对象居民端用户resi政府端工作人员gov运营端工作人员oper
*/
private String app;
/**
* 消息标题
*/
private String title;
/**
* 消息通知内容
*/
private String messageContent;
/**
* read已读unread未读
*/
private String readFlag;
}

77
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/UserMessageExcel.java

@ -0,0 +1,77 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 用户消息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-07
*/
@Data
public class UserMessageExcel {
@Excel(name = "主键")
private String id;
@Excel(name = "客户id")
private String customerId;
@Excel(name = "app=resi时,此列为gridId,其他情况暂定 *")
private String gridId;
@Excel(name = "对应用户id")
private String userId;
@Excel(name = "消息通知对象:居民端用户resi、政府端工作人员gov、运营端工作人员oper")
private String app;
@Excel(name = "消息标题")
private String title;
@Excel(name = "消息通知内容")
private String messageContent;
@Excel(name = "read已读、unread未读")
private String readFlag;
@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;
}

47
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/UserMessageRedis.java

@ -0,0 +1,47 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.redis;
import com.epmet.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 用户消息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-07
*/
@Component
public class UserMessageRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

104
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/UserMessageService.java

@ -0,0 +1,104 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.UserMessageDTO;
import com.epmet.entity.UserMessageEntity;
import java.util.List;
import java.util.Map;
/**
* 用户消息表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-07
*/
public interface UserMessageService extends BaseService<UserMessageEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<UserMessageDTO>
* @author generator
* @date 2020-04-07
*/
PageData<UserMessageDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<UserMessageDTO>
* @author generator
* @date 2020-04-07
*/
List<UserMessageDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return UserMessageDTO
* @author generator
* @date 2020-04-07
*/
UserMessageDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2020-04-07
*/
void save(UserMessageDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2020-04-07
*/
void update(UserMessageDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2020-04-07
*/
void delete(String[] ids);
/**
* 全部已读
*
* @param messageDTO 参数
* @return Result
*/
Result allRead(UserMessageDTO messageDTO);
}

116
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/UserMessageServiceImpl.java

@ -0,0 +1,116 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.UserMessageDao;
import com.epmet.dto.UserMessageDTO;
import com.epmet.entity.UserMessageEntity;
import com.epmet.redis.UserMessageRedis;
import com.epmet.service.UserMessageService;
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 generator generator@elink-cn.com
* @since v1.0.0 2020-04-07
*/
@Service
public class UserMessageServiceImpl extends BaseServiceImpl<UserMessageDao, UserMessageEntity> implements UserMessageService {
@Autowired
private UserMessageRedis userMessageRedis;
@Override
public PageData<UserMessageDTO> page(Map<String, Object> params) {
IPage<UserMessageEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, UserMessageDTO.class);
}
@Override
public List<UserMessageDTO> list(Map<String, Object> params) {
List<UserMessageEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, UserMessageDTO.class);
}
private QueryWrapper<UserMessageEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
String communityId = (String) params.get(FieldConstant.COMMUNITY_ID_HUMP);
String gridId = (String) params.get(FieldConstant.GRID_ID_HUMP);
String userId = (String) params.get(FieldConstant.USER_ID_HUMP);
QueryWrapper<UserMessageEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id)
.eq(StringUtils.isNotBlank(communityId), FieldConstant.COMMUNITY_ID, communityId)
.eq(StringUtils.isNotBlank(gridId), FieldConstant.GRID_ID, gridId)
.eq(StringUtils.isNotBlank(userId), FieldConstant.USER_ID, userId);
return wrapper;
}
@Override
public UserMessageDTO get(String id) {
UserMessageEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, UserMessageDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(UserMessageDTO dto) {
UserMessageEntity entity = ConvertUtils.sourceToTarget(dto, UserMessageEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(UserMessageDTO dto) {
UserMessageEntity entity = ConvertUtils.sourceToTarget(dto, UserMessageEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public Result allRead(UserMessageDTO messageDTO) {
return null;
}
}

27
epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/UserMessageDao.xml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.UserMessageDao">
<resultMap type="com.epmet.entity.UserMessageEntity" id="userMessageMap">
<result property="id" column="ID"/>
<result property="customerId" column="customer_id"/>
<result property="gridId" column="grid_id"/>
<result property="userId" column="user_id"/>
<result property="app" column="app"/>
<result property="title" column="title"/>
<result property="messageContent" column="message_content"/>
<result property="readFlag" column="read_flag"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<update id="updateReadFlag" parameterType="com.epmet.entity.UserMessageEntity">
</update>
</mapper>
Loading…
Cancel
Save