浏览代码

消息管理--列表、搜索、消息模块

ZhangManMan 2 年之前
父节点
当前提交
9dfd48c331

+ 43 - 0
src/main/java/com/sky/ioc/controller/message/MessageController.java

@@ -0,0 +1,43 @@
+package com.sky.ioc.controller.message;
+
+import com.sky.ioc.service.message.MessageService;
+import com.sky.ioc.tool.ReturnMsg;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@Api(tags = "消息管理")
+@Slf4j
+@RestController
+@RequestMapping("/message")
+public class MessageController {
+
+    @Autowired
+    MessageService messageService;
+
+    @ApiOperation("获取消息列表")
+    @GetMapping(value = "/message_list")
+    public ReturnMsg getMessageList() {
+        return messageService.getList();
+    }
+
+    @ApiOperation("获取消息列表")
+    @GetMapping(value = "/messager_module")
+    public ReturnMsg getMessagerModuleList() {
+        return messageService.getTypeList();
+    }
+
+    @ApiOperation("获取消息列表")
+    @GetMapping(value = "/search")
+    public ReturnMsg search(@RequestParam(name = "name",defaultValue = "") String name,
+                            @RequestParam(name = "type",defaultValue = "") String type,
+                            @RequestParam(name = "start_time",defaultValue = "") String start_time,
+                            @RequestParam(name = "end_time",defaultValue = "") String end_time) {
+        return messageService.search(name,type,start_time,end_time);
+    }
+}

+ 1 - 1
src/main/java/com/sky/ioc/controller/organzation/CompanyController.java

@@ -21,7 +21,7 @@ public class CompanyController {
 
     @ApiOperation("获取公司详情")
     @GetMapping(value = "/{company_id}")
-    public ReturnMsg getJobList(@PathVariable Integer company_id) {
+    public ReturnMsg getCompany(@PathVariable Integer company_id) {
         return companyService.getCompany(company_id);
     }
 }

+ 1 - 1
src/main/java/com/sky/ioc/controller/strategy/StrategyController.java

@@ -22,7 +22,7 @@ public class StrategyController {
 
     @ApiOperation("获取策略列表")
     @GetMapping(value = "")
-    public ReturnMsg getJobList() {
+    public ReturnMsg getStrategyList() {
         return meetingRoomService.getList();
     }
 }

+ 20 - 0
src/main/java/com/sky/ioc/entity/domain/message/Message.java

@@ -0,0 +1,20 @@
+package com.sky.ioc.entity.domain.message;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+@Data
+public class Message {
+
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+    private String name;//消息名称')
+    private String pipeline;//通道配置')
+    private String staff;//人员配置')
+    private String send_time;//发送时间')
+    private String title;//标题')
+    private String content;//内容')
+    private String style;//样式')
+    private String type;//消息类型')
+}

+ 55 - 0
src/main/java/com/sky/ioc/enums/MessageTypeEnums.java

@@ -0,0 +1,55 @@
+package com.sky.ioc.enums;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum MessageTypeEnums {
+
+    MESSAGE_TYPE_COMMON(1, "普通消息"),
+    MESSAGE_TYPE_REMIND(2, "提醒消息");
+
+    private Integer type;
+
+    private String desc;
+
+    private MessageTypeEnums(Integer type, String desc) {
+        this.type = type;
+        this.desc = desc;
+    }
+
+    public static String getValue(Integer type) {
+        MessageTypeEnums[] messageTypeEnumss = values();
+        for (MessageTypeEnums messageTypeEnums : messageTypeEnumss) {
+            if (messageTypeEnums.type().equals(type)) {
+                return messageTypeEnums.desc();
+            }
+        }
+        return null;
+    }
+
+    public static Integer getType(String desc) {
+        MessageTypeEnums[] messageTypeEnumss = values();
+        for (MessageTypeEnums messageTypeEnums : messageTypeEnumss) {
+            if (messageTypeEnums.desc().equals(desc)) {
+                return messageTypeEnums.type();
+            }
+        }
+        return null;
+    }
+    public static List<String> getValues() {
+        List<String> values = new ArrayList<>();
+        MessageTypeEnums[] messageTypeEnumss = values();
+        for (MessageTypeEnums messageTypeEnums : messageTypeEnumss) {
+            values.add(messageTypeEnums.desc);
+        }
+        return values;
+    }
+
+    private Integer type() {
+        return this.type;
+    }
+
+    private String desc() {
+        return this.desc;
+    }
+}

+ 9 - 0
src/main/java/com/sky/ioc/mapper/message/MessageMapper.java

@@ -0,0 +1,9 @@
+package com.sky.ioc.mapper.message;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sky.ioc.entity.domain.message.Message;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface MessageMapper extends BaseMapper<Message> {
+}

+ 13 - 0
src/main/java/com/sky/ioc/service/message/MessageService.java

@@ -0,0 +1,13 @@
+package com.sky.ioc.service.message;
+
+import com.sky.ioc.tool.ReturnMsg;
+
+public interface MessageService {
+
+    ReturnMsg getList();
+
+    ReturnMsg getTypeList();
+
+    ReturnMsg search(String name,String type,String start_time,String end_time);
+
+}

+ 55 - 0
src/main/java/com/sky/ioc/service/message/impl/MessageServiceImpl.java

@@ -0,0 +1,55 @@
+package com.sky.ioc.service.message.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.sky.ioc.entity.domain.message.Message;
+import com.sky.ioc.enums.MessageTypeEnums;
+import com.sky.ioc.mapper.message.MessageMapper;
+import com.sky.ioc.service.message.MessageService;
+import com.sky.ioc.tool.ReturnMsg;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Arrays;
+import java.util.List;
+
+@Service
+public class MessageServiceImpl implements MessageService {
+
+    @Autowired
+    MessageMapper messageMapper;
+
+    @Override
+    public ReturnMsg getList() {
+        JSONObject json = new JSONObject();
+        List<String> types = MessageTypeEnums.getValues();
+        for(String type:types){
+            List<Message> messages = messageMapper.selectList(new LambdaQueryWrapper<Message>().eq(Message::getType,type));
+            json.put(type,messages);
+        }
+        return ReturnMsg.ok(json);
+    }
+
+    @Override
+    public ReturnMsg getTypeList() {
+        List<String> types = MessageTypeEnums.getValues();
+        return ReturnMsg.ok(types);
+    }
+
+    @Override
+    public ReturnMsg search(String name, String type, String start_time, String end_time) {
+       LambdaQueryWrapper<Message> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+       if(StringUtils.isNotBlank(name)){
+           lambdaQueryWrapper.eq(Message::getName,name);
+       }
+       if(StringUtils.isNotBlank(type)){
+           lambdaQueryWrapper.eq(Message::getType,type);
+       }
+       if(StringUtils.isNotBlank(start_time)&&StringUtils.isNotBlank(end_time)){
+           lambdaQueryWrapper.between(Message::getSend_time,start_time,end_time);
+       }
+        List<Message> list = messageMapper.selectList(lambdaQueryWrapper);
+        return ReturnMsg.ok(list);
+    }
+}