From 7feb5da469c412676ef73513969cabd9a5616063 Mon Sep 17 00:00:00 2001 From: linhw <5331581+linhw11@user.noreply.gitee.com> Date: Wed, 29 May 2024 17:00:03 +0800 Subject: [PATCH] ~ --- .../app/controller/AppMessageController.java | 114 ++++++++++++++++ .../com/ruoyi/app/domain/AppFeedback.java | 2 + .../java/com/ruoyi/app/domain/AppMessage.java | 91 +++++++++++++ .../ruoyi/app/mapper/AppMessageMapper.java | 62 +++++++++ .../ruoyi/app/service/IAppMessageService.java | 61 +++++++++ .../service/impl/AppMessageServiceImpl.java | 124 ++++++++++++++++++ .../resources/mapper/app/AppMessageMapper.xml | 92 +++++++++++++ 7 files changed, 546 insertions(+) create mode 100644 gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppMessageController.java create mode 100644 gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/AppMessage.java create mode 100644 gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppMessageMapper.java create mode 100644 gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppMessageService.java create mode 100644 gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppMessageServiceImpl.java create mode 100644 gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppMessageMapper.xml diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppMessageController.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppMessageController.java new file mode 100644 index 0000000..d23f171 --- /dev/null +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/AppMessageController.java @@ -0,0 +1,114 @@ +package com.ruoyi.app.controller; + +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.core.domain.R; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.app.domain.AppMessage; +import com.ruoyi.app.service.IAppMessageService; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.page.TableDataInfo; + +/** + * 系统消息Controller + * + * @author wyh + * @date 2024-05-29 + */ +@RestController +@RequestMapping("/message") +@Api(tags = "系统消息" , description = "系统消息") +public class AppMessageController extends BaseController +{ + @Autowired + private IAppMessageService appMessageService; + + /** + * 查询系统消息列表 + */ + @RequiresPermissions("app:message:list") + @GetMapping("/list") + @ApiOperation(value = "查询系统消息", notes = "查询系统消息", httpMethod = "GET") + public TableDataInfo list(AppMessage appMessage) + { + startPage(); + List list = appMessageService.selectAppMessageList(appMessage); + return getDataTable(list); + } + + /** + * 导出系统消息列表 + */ + @RequiresPermissions("app:message:export") + @Log(title = "系统消息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, AppMessage appMessage) + { + List list = appMessageService.selectAppMessageList(appMessage); + ExcelUtil util = new ExcelUtil(AppMessage.class); + util.exportExcel(response, list, "系统消息数据"); + } + + /** + * 获取系统消息详细信息 + */ + @RequiresPermissions("app:message:query") + @GetMapping(value = "/{id}") + @ApiOperation(value = "获取系统消息详细信息", notes = "获取系统消息详细信息", httpMethod = "GET") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(appMessageService.selectAppMessageById(id)); + } + + /** + * 新增系统消息 + */ + @RequiresPermissions("app:message:add") + @ApiOperation(value = "新增系统消息", notes = "新增系统消息", httpMethod = "POST") + @Log(title = "系统消息", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult add(@RequestBody AppMessage appMessage) + { + return toAjax(appMessageService.insertAppMessage(appMessage)); + } + + /** + * 修改系统消息 + */ + @RequiresPermissions("app:message:edit") + @ApiOperation(value = "修改系统消息", notes = "修改系统消息", httpMethod = "PUT") + @Log(title = "系统消息", businessType = BusinessType.UPDATE) + @PutMapping("/edit") + public AjaxResult edit(@RequestBody AppMessage appMessage) + { + return toAjax(appMessageService.updateAppMessage(appMessage)); + } + + /** + * 删除系统消息 + */ + @RequiresPermissions("app:message:remove") + @Log(title = "系统消息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(appMessageService.deleteAppMessageByIds(ids)); + } +} diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/AppFeedback.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/AppFeedback.java index e15dfb3..cdc6984 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/AppFeedback.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/AppFeedback.java @@ -1,5 +1,6 @@ package com.ruoyi.app.domain; +import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.core.annotation.Excel; @@ -11,6 +12,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity; * @author wyh * @date 2024-05-29 */ +@Data public class AppFeedback extends BaseEntity { private static final long serialVersionUID = 1L; diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/AppMessage.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/AppMessage.java new file mode 100644 index 0000000..e93a5f1 --- /dev/null +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/domain/AppMessage.java @@ -0,0 +1,91 @@ +package com.ruoyi.app.domain; + +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 系统消息对象 app_message + * + * @author wyh + * @date 2024-05-29 + */ +@Data +public class AppMessage extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 管理员id */ + @Excel(name = "管理员id") + private Long userId; + + /** 通知内容 */ + @Excel(name = "通知内容") + private String content; + + /** 图片 */ + @Excel(name = "图片") + private String imgUrl; + + + @Excel(name = "头像") + private String avatarUrl; + + @Excel(name = "用户名") + private String username; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getUserId() + { + return userId; + } + public void setContent(String content) + { + this.content = content; + } + + public String getContent() + { + return content; + } + public void setImgUrl(String imgUrl) + { + this.imgUrl = imgUrl; + } + + public String getImgUrl() + { + return imgUrl; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("userId", getUserId()) + .append("content", getContent()) + .append("imgUrl", getImgUrl()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppMessageMapper.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppMessageMapper.java new file mode 100644 index 0000000..037ff8a --- /dev/null +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/mapper/AppMessageMapper.java @@ -0,0 +1,62 @@ +package com.ruoyi.app.mapper; + +import java.util.List; +import com.ruoyi.app.domain.AppMessage; + +/** + * 系统消息Mapper接口 + * + * @author wyh + * @date 2024-05-29 + */ +public interface AppMessageMapper +{ + /** + * 查询系统消息 + * + * @param id 系统消息主键 + * @return 系统消息 + */ + public AppMessage selectAppMessageById(Long id); + + /** + * 查询系统消息列表 + * + * @param appMessage 系统消息 + * @return 系统消息集合 + */ + public List selectAppMessageList(AppMessage appMessage); + public List selectList(AppMessage appMessage); + + /** + * 新增系统消息 + * + * @param appMessage 系统消息 + * @return 结果 + */ + public int insertAppMessage(AppMessage appMessage); + + /** + * 修改系统消息 + * + * @param appMessage 系统消息 + * @return 结果 + */ + public int updateAppMessage(AppMessage appMessage); + + /** + * 删除系统消息 + * + * @param id 系统消息主键 + * @return 结果 + */ + public int deleteAppMessageById(Long id); + + /** + * 批量删除系统消息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteAppMessageByIds(Long[] ids); +} diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppMessageService.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppMessageService.java new file mode 100644 index 0000000..50f0af6 --- /dev/null +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/IAppMessageService.java @@ -0,0 +1,61 @@ +package com.ruoyi.app.service; + +import java.util.List; +import com.ruoyi.app.domain.AppMessage; + +/** + * 系统消息Service接口 + * + * @author wyh + * @date 2024-05-29 + */ +public interface IAppMessageService +{ + /** + * 查询系统消息 + * + * @param id 系统消息主键 + * @return 系统消息 + */ + public AppMessage selectAppMessageById(Long id); + + /** + * 查询系统消息列表 + * + * @param appMessage 系统消息 + * @return 系统消息集合 + */ + public List selectAppMessageList(AppMessage appMessage); + + /** + * 新增系统消息 + * + * @param appMessage 系统消息 + * @return 结果 + */ + public int insertAppMessage(AppMessage appMessage); + + /** + * 修改系统消息 + * + * @param appMessage 系统消息 + * @return 结果 + */ + public int updateAppMessage(AppMessage appMessage); + + /** + * 批量删除系统消息 + * + * @param ids 需要删除的系统消息主键集合 + * @return 结果 + */ + public int deleteAppMessageByIds(Long[] ids); + + /** + * 删除系统消息信息 + * + * @param id 系统消息主键 + * @return 结果 + */ + public int deleteAppMessageById(Long id); +} diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppMessageServiceImpl.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppMessageServiceImpl.java new file mode 100644 index 0000000..c98f566 --- /dev/null +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppMessageServiceImpl.java @@ -0,0 +1,124 @@ +package com.ruoyi.app.service.impl; + +import java.util.List; + +import com.ruoyi.app.domain.AppUser; +import com.ruoyi.app.mapper.AppUserMapper; +import com.ruoyi.common.core.utils.DateUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.app.mapper.AppMessageMapper; +import com.ruoyi.app.domain.AppMessage; +import com.ruoyi.app.service.IAppMessageService; + +/** + * 系统消息Service业务层处理 + * + * @author wyh + * @date 2024-05-29 + */ +@Service +public class AppMessageServiceImpl implements IAppMessageService +{ + @Autowired + private AppMessageMapper appMessageMapper; + + @Autowired + private AppUserMapper appUserMapper; + + /** + * 查询系统消息 + * + * @param id 系统消息主键 + * @return 系统消息 + */ + @Override + public AppMessage selectAppMessageById(Long id) + { + return appMessageMapper.selectAppMessageById(id); + } + + /** + * 查询系统消息列表 + * + * @param appMessage 系统消息 + * @return 系统消息 + */ + @Override + public List selectAppMessageList(AppMessage appMessage) + { + return appMessageMapper.selectList(appMessage); + } + + /** + * 新增系统消息 + * + * @param appMessage 系统消息 + * @return 结果 + */ + @Override + public int insertAppMessage(AppMessage appMessage) + { + appMessage.setCreateTime(DateUtils.getNowDate()); + List appUsers = appUserMapper.selectAppUserList(new AppUser()); + for (AppUser appUser : appUsers) { + if (appUser.getPushId() == null) { + continue; + } + HttpClient httpClient = HttpClients.createDefault(); + String url = "https://tcb-am7ffkwasxkewhf-3cpy096b83a1.service.tcloudbase.com/urlPush/pushId?pushId=" + appUser.getPushId() + "&content=" + appMessage.getContent(); + try { + HttpGet request = new HttpGet(url); + HttpResponse response = httpClient.execute(request); + // Get the response entity as a String + String jsonResponse = EntityUtils.toString(response.getEntity()); + System.out.println(jsonResponse); + } catch (Exception e) { + e.printStackTrace(); + } + } + return appMessageMapper.insertAppMessage(appMessage); + } + + /** + * 修改系统消息 + * + * @param appMessage 系统消息 + * @return 结果 + */ + @Override + public int updateAppMessage(AppMessage appMessage) + { + appMessage.setUpdateTime(DateUtils.getNowDate()); + return appMessageMapper.updateAppMessage(appMessage); + } + + /** + * 批量删除系统消息 + * + * @param ids 需要删除的系统消息主键 + * @return 结果 + */ + @Override + public int deleteAppMessageByIds(Long[] ids) + { + return appMessageMapper.deleteAppMessageByIds(ids); + } + + /** + * 删除系统消息信息 + * + * @param id 系统消息主键 + * @return 结果 + */ + @Override + public int deleteAppMessageById(Long id) + { + return appMessageMapper.deleteAppMessageById(id); + } +} diff --git a/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppMessageMapper.xml b/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppMessageMapper.xml new file mode 100644 index 0000000..ccaeb43 --- /dev/null +++ b/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppMessageMapper.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + select id, user_id, content, img_url, create_time, update_time, remark from app_message + + + + + + + + + + insert into app_message + + user_id, + content, + img_url, + create_time, + update_time, + remark, + + + #{userId}, + #{content}, + #{imgUrl}, + #{createTime}, + #{updateTime}, + #{remark}, + + + + + update app_message + + user_id = #{userId}, + content = #{content}, + img_url = #{imgUrl}, + create_time = #{createTime}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from app_message where id = #{id} + + + + delete from app_message where id in + + #{id} + + + \ No newline at end of file