From 07a2b6177b40c904408b18c03e97d6e20b664bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=AA=E5=AF=92?= <2533659732@qq.com> Date: Tue, 16 Apr 2024 14:17:14 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E9=99=A2=E5=90=8E=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=99=BB=E5=BD=95=E5=92=8C=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 2 +- .../com/xinelu/common/constant/Constants.java | 30 +++++ .../residentinfo/ResidentInfoMapper.java | 13 +- .../residentinfo/ResidentInfoMapper.xml | 14 ++ .../AppletPersonCenterController.java | 54 ++++++++ .../AppletPersonCenterService.java | 29 +++++ .../Impl/AppletPersonCenterServiceImpl.java | 123 ++++++++++++++++++ .../mobile/utils/WeChatAppletUtils.java | 50 +++++++ .../PostDischargeAppletPhoneVO.java | 85 ++++++++++++ .../PostDischargeAppletVO.java | 39 ++++++ 10 files changed, 437 insertions(+), 2 deletions(-) create mode 100644 postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java create mode 100644 postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java create mode 100644 postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java create mode 100644 postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/appletpersoncenter/PostDischargeAppletPhoneVO.java create mode 100644 postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/appletpersoncenter/PostDischargeAppletVO.java diff --git a/postdischarge-admin/src/main/resources/application.yml b/postdischarge-admin/src/main/resources/application.yml index c6131886..0671ce1a 100644 --- a/postdischarge-admin/src/main/resources/application.yml +++ b/postdischarge-admin/src/main/resources/application.yml @@ -103,7 +103,7 @@ token: # 令牌有效期(默认30分钟) expireTime: 30 # 请求拦截白名单 - ant-matchers: /postDischarge/**,/testMobile/** + ant-matchers: /postDischarge/**,/testMobile/**,/postDischargeApplet/** ## MyBatis-Plus配置 mybatis-plus: diff --git a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java index 9ae03f9a..0102e27c 100644 --- a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java +++ b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java @@ -283,4 +283,34 @@ public class Constants { * 成功 */ public static final int SUCCESS_ERROR_CODE = 0; + + /** + * 院后微信小程序登录接口地址 + */ + public static final String APPLET_LOGIN_URL = "https://api.weixin.qq.com/sns/jscode2session"; + + /** + * 微信小程序ACCESS_TOKEN前缀 + */ + public static final String POST_DISCHARGE_APPLET_ACCESS_TOKEN = "POST_Discharge_APPLET_ACCESS_TOKEN_"; + + /** + * 返回成功状态码 + */ + public static final int SUCCESS_CODE = 0; + + /** + * 院后微信小程序获取用户手机号接口地址 + */ + public static final String PHONE_NUMBER_URL = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token="; + + /** + * 获取微信小程序access_token错误码 + */ + public static final int ERROR_ACCESS_CODE = 40001; + + /** + * 返回成功状态码 + */ + public static final String OK = "ok"; } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/residentinfo/ResidentInfoMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/residentinfo/ResidentInfoMapper.java index 771126ec..daeb251c 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/residentinfo/ResidentInfoMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/residentinfo/ResidentInfoMapper.java @@ -1,6 +1,8 @@ package com.xinelu.manage.mapper.residentinfo; import com.xinelu.manage.domain.residentinfo.ResidentInfo; +import org.apache.ibatis.annotations.Param; + import java.util.List; @@ -17,7 +19,7 @@ public interface ResidentInfoMapper { * @param id 居民信息主键 * @return 居民信息 */ - public ResidentInfo selectResidentInfoById(Long id); + ResidentInfo selectResidentInfoById(Long id); /** * 查询居民信息列表 @@ -58,4 +60,13 @@ public interface ResidentInfoMapper { * @return 结果 */ int deleteResidentInfoByIds(Long[] ids); + + /** + * 根据电话号码和微信小程序openid查询居民基本信息 + * + * @param phone 手机号 + * @param openId 微信小程序openId + * @return 被护理人基本信息 + */ + ResidentInfo getResidentInfoByPhoneAndOpenId(@Param("phone") String phone, @Param("openId") String openId); } diff --git a/postdischarge-manage/src/main/resources/mapper/manage/residentinfo/ResidentInfoMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/residentinfo/ResidentInfoMapper.xml index 1c5ae83d..366b49e2 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/residentinfo/ResidentInfoMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/residentinfo/ResidentInfoMapper.xml @@ -183,4 +183,18 @@ #{id} + + \ No newline at end of file diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java new file mode 100644 index 00000000..2bf9b0de --- /dev/null +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java @@ -0,0 +1,54 @@ +package com.xinelu.mobile.controller.appletpersoncenter; + +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.mobile.service.appletpersoncenter.AppletPersonCenterService; +import org.apache.commons.lang3.StringUtils; +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; + +import javax.annotation.Resource; + +/** + * @Description 院后小程序个人中心控制器 + * @Author 纪寒 + * @Date 2024-04-16 10:49:14 + * @Version 1.0 + */ +@RestController +@RequestMapping("/postDischargeApplet") +public class AppletPersonCenterController { + + @Resource + private AppletPersonCenterService appletPersonCenterService; + + /** + * 院后微信小程序一键登录接口 + * + * @param loginCode 登录凭证 + * @param phoneCode 获取手机号登录凭证 + * @return 微信小程序用户登录信息 + */ + @GetMapping("/appletLogin") + public AjaxResult appletLogin(@RequestParam("loginCode") String loginCode, @RequestParam("phoneCode") String phoneCode) { + if (StringUtils.isBlank(loginCode)) { + return AjaxResult.error("登录凭证编码不能为空!"); + } + if (StringUtils.isBlank(phoneCode)) { + return AjaxResult.error("用户手机号凭证不存在"); + } + return appletPersonCenterService.appletLogin(loginCode, phoneCode); + } + + /** + * 根据居民表id查询患者个人信息 + * + * @param residentId 居民表id + * @return 个人信息 + */ + @GetMapping("/getResidentInfoById") + public AjaxResult getResidentInfoById(Long residentId) { + return appletPersonCenterService.getResidentInfoById(residentId); + } +} diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java new file mode 100644 index 00000000..2a4dc85f --- /dev/null +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java @@ -0,0 +1,29 @@ +package com.xinelu.mobile.service.appletpersoncenter; + +import com.xinelu.common.core.domain.AjaxResult; + +/** + * @Description 院后小程序个人中心业务层 + * @Author 纪寒 + * @Date 2024-04-16 10:51:28 + * @Version 1.0 + */ +public interface AppletPersonCenterService { + + /** + * 院后微信小程序一键登录接口 + * + * @param loginCode 登录凭证 + * @param phoneCode 获取手机号登录凭证 + * @return 微信小程序用户登录信息 + */ + AjaxResult appletLogin(String loginCode, String phoneCode); + + /** + * 根据居民表id查询患者个人信息 + * + * @param residentId 居民表id + * @return 个人信息 + */ + AjaxResult getResidentInfoById(Long residentId); +} diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java new file mode 100644 index 00000000..8fe5f36e --- /dev/null +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java @@ -0,0 +1,123 @@ +package com.xinelu.mobile.service.appletpersoncenter.Impl; + +import com.xinelu.common.config.WeChatAppletChatConfig; +import com.xinelu.common.constant.Constants; +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.manage.domain.residentinfo.ResidentInfo; +import com.xinelu.manage.mapper.residentinfo.ResidentInfoMapper; +import com.xinelu.mobile.service.appletpersoncenter.AppletPersonCenterService; +import com.xinelu.mobile.utils.WeChatAppletUtils; +import com.xinelu.mobile.vo.appletpersoncenter.PostDischargeAppletPhoneVO; +import com.xinelu.mobile.vo.appletpersoncenter.PostDischargeAppletVO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.util.Objects; + +/** + * @Description 院后小程序个人中心业务层实现类 + * @Author 纪寒 + * @Date 2024-04-16 10:52:09 + * @Version 1.0 + */ +@Service +@Slf4j +public class AppletPersonCenterServiceImpl implements AppletPersonCenterService { + + @Resource + private WeChatAppletUtils weChatAppletUtils; + @Resource + private WeChatAppletChatConfig weChatAppletChatConfig; + @Resource + private RedisTemplate redisTemplate; + @Resource + private ResidentInfoMapper residentInfoMapper; + + /** + * 院后微信小程序一键登录接口 + * + * @param loginCode 登录凭证 + * @param phoneCode 获取手机号登录凭证 + * @return 微信小程序用户登录信息 + */ + @Override + public AjaxResult appletLogin(String loginCode, String phoneCode) { + //根据code获取用户的微信unionId以及openId等信息 + PostDischargeAppletVO appletLoginInfo = weChatAppletUtils.getPostDischargeAppletLogin(weChatAppletChatConfig.getAppletId(), weChatAppletChatConfig.getSecret(), loginCode, weChatAppletChatConfig.getGrantType()); + if (Objects.isNull(appletLoginInfo)) { + return AjaxResult.error("获取院后微信小程序用户信息失败"); + } + if (Objects.nonNull(appletLoginInfo.getErrcode()) && appletLoginInfo.getErrcode() != Constants.SUCCESS_CODE) { + return AjaxResult.error("获取院后微信小程序用户信息失败,失败信息为:" + appletLoginInfo.getErrmsg()); + } + //获取微信accessToken + String accessToken; + String accessTokenKey = Constants.POST_DISCHARGE_APPLET_ACCESS_TOKEN + "accessToken"; + //从Redis中取出accessToken + Object object = redisTemplate.opsForValue().get(accessTokenKey); + if (Objects.isNull(object)) { + accessToken = weChatAppletUtils.getWeChatAppletAccessToken(); + } else { + accessToken = (String) object; + } + //获取用户手机号 + PostDischargeAppletPhoneVO appletPhoneInfo = weChatAppletUtils.getPostDischargeAppletPhone(phoneCode, accessToken); + if (Objects.isNull(appletPhoneInfo)) { + return AjaxResult.error("获取用户手机号失败"); + } + if (Objects.nonNull(appletPhoneInfo.getErrcode()) && appletPhoneInfo.getErrcode() == Constants.ERROR_ACCESS_CODE) { + //当前Redis缓存中的access_token无效直接删除 + if (Objects.nonNull(object)) { + redisTemplate.delete(accessTokenKey); + //删除之后重新获取获取accessToken + accessToken = weChatAppletUtils.getWeChatAppletAccessToken(); + appletPhoneInfo = weChatAppletUtils.getPostDischargeAppletPhone(phoneCode, accessToken); + if (Objects.isNull(appletPhoneInfo)) { + return AjaxResult.error("获取用户手机号失败"); + } + if (Objects.nonNull(appletPhoneInfo.getErrcode()) && appletPhoneInfo.getErrcode() == Constants.ERROR_ACCESS_CODE) { + return AjaxResult.error("登录失败!"); + } + } + } + if (StringUtils.isNotBlank(appletPhoneInfo.getErrmsg()) && !Constants.OK.equals(appletPhoneInfo.getErrmsg())) { + return AjaxResult.error("获取用户手机号失败,失败信息为:" + appletPhoneInfo.getErrmsg()); + } + //根据手机号和微信小程序openid判断当前用户是否存在 + String phone = StringUtils.isBlank(appletPhoneInfo.getPhoneInfo().getPhoneNumber()) ? "" : appletPhoneInfo.getPhoneInfo().getPhoneNumber(); + String openId = StringUtils.isBlank(appletLoginInfo.getOpenid()) ? "" : appletLoginInfo.getOpenid(); + ResidentInfo residentInfoByPhone = residentInfoMapper.getResidentInfoByPhoneAndOpenId(null, openId); + ResidentInfo residentInfo = new ResidentInfo(); + //居民信息为空新增个人信息 + if (Objects.isNull(residentInfoByPhone)) { + residentInfo.setOpenId(openId); + residentInfo.setPatientPhone(phone); + residentInfo.setCreateTime(LocalDateTime.now()); + residentInfoMapper.insertResidentInfo(residentInfo); + residentInfo.setId(residentInfo.getId()); + return AjaxResult.success(residentInfo); + } + //更新居民信息的openid等微信标识信息 + residentInfo.setId(residentInfoByPhone.getId()); + residentInfo.setOpenId(openId); + residentInfo.setPatientPhone(StringUtils.isBlank(residentInfoByPhone.getPatientPhone()) ? "" : residentInfoByPhone.getPatientPhone()); + residentInfo.setUpdateTime(LocalDateTime.now()); + residentInfoMapper.updateResidentInfo(residentInfo); + return AjaxResult.success(residentInfo); + } + + /** + * 根据居民表id查询患者个人信息 + * + * @param residentId 居民表id + * @return 个人信息 + */ + @Override + public AjaxResult getResidentInfoById(Long residentId) { + return AjaxResult.success(residentInfoMapper.selectResidentInfoById(residentId)); + } +} diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/utils/WeChatAppletUtils.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/utils/WeChatAppletUtils.java index 62b2cba8..86ff58b8 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/utils/WeChatAppletUtils.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/utils/WeChatAppletUtils.java @@ -6,11 +6,15 @@ import com.xinelu.common.constant.Constants; import com.xinelu.common.entity.AccessToken; import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.http.HttpUtils; +import com.xinelu.mobile.vo.appletpersoncenter.PostDischargeAppletPhoneVO; +import com.xinelu.mobile.vo.appletpersoncenter.PostDischargeAppletVO; import org.apache.commons.lang3.StringUtils; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; import java.util.concurrent.TimeUnit; @@ -68,4 +72,50 @@ public class WeChatAppletUtils { } return accessToken; } + + /** + * 根据登录编码获取微信小程序用户信息 + * + * @param appletId 小程序id + * @param secret 小程序秘钥 + * @param code 登录凭证码 + * @param grantType 授权类型 + * @return 登录信息 + */ + public PostDischargeAppletVO getPostDischargeAppletLogin(String appletId, String secret, String code, String grantType) { + //请求地址 + String appletLoginUrl = Constants.APPLET_LOGIN_URL + + "?appid=" + appletId + + "&secret=" + secret + + "&js_code=" + code + + "&grant_type=" + grantType; + //发送请求 + String result = HttpUtils.sendGet(appletLoginUrl); + if (StringUtils.isBlank(result)) { + throw new ServiceException("获取院后微信小程序用户信息失败", 201); + } + return JSON.parseObject(result, PostDischargeAppletVO.class); + } + + /** + * 获取院后微信小程序的手机号码 + * + * @param code 登录凭证 + * @param accessToken 小程序accessToken + * @return 手机信息 + */ + public PostDischargeAppletPhoneVO getPostDischargeAppletPhone(String code, String accessToken) { + //请求地址 + String phoneUrl = Constants.PHONE_NUMBER_URL + accessToken; + //请求参数 + Map paramMap = new HashMap<>(); + paramMap.put("code", code); + String param = JSON.toJSONString(paramMap); + //发送POST请求 + String result = HttpUtils.sendPostJson(phoneUrl, param); + if (StringUtils.isBlank(result)) { + throw new ServiceException("获取院后微信小程序手机号失败", 201); + } + return JSON.parseObject(result, PostDischargeAppletPhoneVO.class); + } } diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/appletpersoncenter/PostDischargeAppletPhoneVO.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/appletpersoncenter/PostDischargeAppletPhoneVO.java new file mode 100644 index 00000000..0f667667 --- /dev/null +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/appletpersoncenter/PostDischargeAppletPhoneVO.java @@ -0,0 +1,85 @@ +package com.xinelu.mobile.vo.appletpersoncenter; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @Description 获取小程序用户手机号实体类 + * @Author 纪寒 + * @Date 2024-04-16 11:15:53 + * @Version 1.0 + */ +@NoArgsConstructor +@Data +public class PostDischargeAppletPhoneVO implements Serializable { + private static final long serialVersionUID = 7053513139462975391L; + /** + * 错误编码, + * 0:成功 + * -1:系统繁忙,此时请开发者稍候再试 + * 40029:不合法的code(code不存在、已过期或者使用过) + */ + @JsonProperty("errcode") + private Integer errcode; + + /** + * 返回提示信息,ok:成功 + */ + @JsonProperty("errmsg") + private String errmsg; + + /** + * 电话信息实体类 + */ + @JsonProperty("phone_info") + private PhoneInfoDTO phoneInfo; + + @NoArgsConstructor + @Data + public static class PhoneInfoDTO { + + /** + * 用户绑定的手机号(国外手机号会有区号) + */ + @JsonProperty("phoneNumber") + private String phoneNumber; + + /** + * 没有区号的手机号 + */ + @JsonProperty("purePhoneNumber") + private String purePhoneNumber; + + /** + * 区号 + */ + @JsonProperty("countryCode") + private Integer countryCode; + + /** + * 数据水印 + */ + @JsonProperty("watermark") + private WatermarkDTO watermark; + + @NoArgsConstructor + @Data + public static class WatermarkDTO { + + /** + * 用户获取手机号操作的时间戳 + */ + @JsonProperty("timestamp") + private Integer timestamp; + + /** + * 小程序appid + */ + @JsonProperty("appid") + private String appid; + } + } +} diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/appletpersoncenter/PostDischargeAppletVO.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/appletpersoncenter/PostDischargeAppletVO.java new file mode 100644 index 00000000..d5929f1d --- /dev/null +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/vo/appletpersoncenter/PostDischargeAppletVO.java @@ -0,0 +1,39 @@ +package com.xinelu.mobile.vo.appletpersoncenter; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 院后微信小程序用户信息实体类 + * @Author 纪寒 + * @Date 2024-04-16 10:56:22 + * @Version 1.0 + */ +@Data +public class PostDischargeAppletVO implements Serializable { + private static final long serialVersionUID = 9163624256938346478L; + /** + * 小程序unionid + */ + private String unionid; + + /** + * 小程序openid + */ + private String openid; + + /** + * 错误状态码,40029:js_code无效,45011:API 调用太频繁,请稍候再试 + * 40226:高风险等级用户,小程序登录拦截 ,-1:系统繁忙,此时请开发者稍候再试 + */ + private Integer errcode; + + /** + * 状态信息,取值有,40029:code 无效, + * 45011:api minute-quota reach limit mustslower retry next minute + * 40226:code blocked + * -1:system error + */ + private String errmsg; +} From e00a55efad51dfb54f658b54b52f5d3ab13b982d Mon Sep 17 00:00:00 2001 From: gognqingkai <1825346742@qq.com> Date: Tue, 16 Apr 2024 15:31:29 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=B5=84=E8=AE=AF=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E8=B5=84=E8=AE=AF=E4=BF=A1=E6=81=AF=E5=92=8C=E8=B5=84=E8=AE=AF?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=AE=9E=E7=8E=B0=20add=20by=20gqk=202024/04?= =?UTF-8?q?/16=2015:29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 7 +- .../common/config/SystemBusinessConfig.java | 13 + .../com/xinelu/common/constant/Constants.java | 15 ++ .../xinelu/common/utils/file/FileUtils.java | 50 ++++ .../controller/info/InfoController.java | 113 +++++++++ .../infocategory/InfoCategoryController.java | 104 ++++++++ .../com/xinelu/manage/domain/info/Info.java | 152 ++++++++++++ .../domain/infocategory/InfoCategory.java | 81 +++++++ .../dto/infocategory/InfoCategoryDTO.java | 17 ++ .../xinelu/manage/mapper/info/InfoMapper.java | 72 ++++++ .../infocategory/InfoCategoryMapper.java | 94 ++++++++ .../manage/service/info/IInfoService.java | 70 ++++++ .../service/info/impl/InfoServiceImpl.java | 225 ++++++++++++++++++ .../infocategory/IInfoCategoryService.java | 65 +++++ .../impl/InfoCategoryServiceImpl.java | 157 ++++++++++++ .../mapper/manage/info/InfoMapper.xml | 223 +++++++++++++++++ .../infocategory/InfoCategoryMapper.xml | 166 +++++++++++++ .../controller/info/MobileInfoController.java | 39 +++ 18 files changed, 1660 insertions(+), 3 deletions(-) create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/controller/info/InfoController.java create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/controller/infocategory/InfoCategoryController.java create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/domain/info/Info.java create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/domain/infocategory/InfoCategory.java create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/dto/infocategory/InfoCategoryDTO.java create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/mapper/info/InfoMapper.java create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/mapper/infocategory/InfoCategoryMapper.java create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/service/info/IInfoService.java create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/service/info/impl/InfoServiceImpl.java create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/service/infocategory/IInfoCategoryService.java create mode 100644 postdischarge-manage/src/main/java/com/xinelu/manage/service/infocategory/impl/InfoCategoryServiceImpl.java create mode 100644 postdischarge-manage/src/main/resources/mapper/manage/info/InfoMapper.xml create mode 100644 postdischarge-manage/src/main/resources/mapper/manage/infocategory/InfoCategoryMapper.xml create mode 100644 postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/info/MobileInfoController.java diff --git a/postdischarge-admin/src/main/resources/application.yml b/postdischarge-admin/src/main/resources/application.yml index c6131886..e7173d4d 100644 --- a/postdischarge-admin/src/main/resources/application.yml +++ b/postdischarge-admin/src/main/resources/application.yml @@ -26,6 +26,8 @@ xinelu: script-file-url: /scriptFileUrl # 获取管理端富文本的上传路径 rich-text-picture-url: /richTextPictureUrl + # 资讯富文本的上传路径 + info-rich-text-picture-url: /infoRichTextPictureUrl # 开发环境配置 server: @@ -80,7 +82,7 @@ spring: # 数据库索引 database: 6 # 密码 - password: xinelu@6990 + password: 123456 # 连接超时时间 timeout: 10s lettuce: @@ -103,8 +105,7 @@ token: # 令牌有效期(默认30分钟) expireTime: 30 # 请求拦截白名单 - ant-matchers: /postDischarge/**,/testMobile/** - + ant-matchers: /postDischarge/**,/testMobile/**,/mobile/** ## MyBatis-Plus配置 mybatis-plus: # 实体扫描,多个package用逗号或者分号分隔 diff --git a/postdischarge-common/src/main/java/com/xinelu/common/config/SystemBusinessConfig.java b/postdischarge-common/src/main/java/com/xinelu/common/config/SystemBusinessConfig.java index a58a3a17..b9ae64c3 100644 --- a/postdischarge-common/src/main/java/com/xinelu/common/config/SystemBusinessConfig.java +++ b/postdischarge-common/src/main/java/com/xinelu/common/config/SystemBusinessConfig.java @@ -71,6 +71,11 @@ public class SystemBusinessConfig { */ private String scriptFileUrl; + /** + * 资讯图片地址 + */ + private String infoRichTextPictureUrl; + /** * 获取管理端富文本的上传路径 */ @@ -206,4 +211,12 @@ public class SystemBusinessConfig { public void setRichTextPictureUrl(String richTextPictureUrl) { this.richTextPictureUrl = richTextPictureUrl; } + + public String getInfoRichTextPictureUrl() { + return infoRichTextPictureUrl; + } + + public void setInfoRichTextPictureUrl(String infoRichTextPictureUrl) { + this.infoRichTextPictureUrl = infoRichTextPictureUrl; + } } diff --git a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java index 9ae03f9a..5f9a2e81 100644 --- a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java +++ b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java @@ -283,4 +283,19 @@ public class Constants { * 成功 */ public static final int SUCCESS_ERROR_CODE = 0; + + /** + * 资讯分类编码前缀 + */ + public static final String INFO_CATEGORY_CODE = "ICC"; + + /** + * 资讯编码前缀 + */ + public static final String INFO_CODE = "IC"; + + /** + * 科室编码前缀 + */ + public static final String DEPARTMENT_CODE = "HDC"; } diff --git a/postdischarge-common/src/main/java/com/xinelu/common/utils/file/FileUtils.java b/postdischarge-common/src/main/java/com/xinelu/common/utils/file/FileUtils.java index e90126b7..131966d3 100644 --- a/postdischarge-common/src/main/java/com/xinelu/common/utils/file/FileUtils.java +++ b/postdischarge-common/src/main/java/com/xinelu/common/utils/file/FileUtils.java @@ -4,6 +4,7 @@ import com.xinelu.common.config.SystemBusinessConfig; import com.xinelu.common.utils.DateUtils; import com.xinelu.common.utils.StringUtils; import com.xinelu.common.utils.uuid.IdUtils; +import org.apache.commons.compress.utils.Lists; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.ArrayUtils; @@ -13,6 +14,10 @@ import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * 文件处理工具类 @@ -22,6 +27,16 @@ import java.nio.charset.StandardCharsets; public class FileUtils { public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; + /** + * 匹配content中的标签 + **/ + private static final String PATTEN_IMG = "<(img|IMG)(.*?)(/>|>|>)"; + + /** + * 匹配标签中的src + **/ + private static final String PATTEN_SRC = "(src|SRC)=(\"|\')(.*?)(\"|\')"; + /** * 输出指定文件的byte数组 * @@ -243,4 +258,39 @@ public class FileUtils { return baseName; } + /** + * 获取img标签中的src值 + * + * @param content img的内容 + * @return List + */ + public static List getImgSrc(String content) { + if (StringUtils.isBlank(content)) { + return Lists.newArrayList(); + } + List list = new ArrayList<>(); + //开始匹配content中的标签 + Pattern pImg = Pattern.compile(PATTEN_IMG); + Matcher mImg = pImg.matcher(content); + boolean resultImg = mImg.find(); + if (resultImg) { + while (resultImg) { + //获取到匹配的标签中的内容 + String strImg = mImg.group(2); + //开始匹配标签中的src + Pattern pSrc = Pattern.compile(PATTEN_SRC); + Matcher mSrc = pSrc.matcher(strImg); + if (mSrc.find()) { + String strSrc = mSrc.group(3); + if (StringUtils.isNotBlank(strSrc)) { + list.add(strSrc); + } + } + //匹配content中是否存在下一个标签,有则继续以上步骤匹配标签中的src + resultImg = mImg.find(); + } + } + return list; + } + } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/info/InfoController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/info/InfoController.java new file mode 100644 index 00000000..5d88d86f --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/info/InfoController.java @@ -0,0 +1,113 @@ +package com.xinelu.manage.controller.info; + +import java.util.List; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; + +import com.xinelu.manage.service.infocategory.IInfoCategoryService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.access.prepost.PreAuthorize; +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.xinelu.common.annotation.Log; +import com.xinelu.common.core.controller.BaseController; +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.enums.BusinessType; +import com.xinelu.manage.domain.info.Info; +import com.xinelu.manage.service.info.IInfoService; +import com.xinelu.common.utils.poi.ExcelUtil; +import com.xinelu.common.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; + +/** + * 资讯信息Controller + * + * @author xinelu + * @date 2024-04-11 + */ +@Slf4j +@RestController +@RequestMapping("/manage/info") +public class InfoController extends BaseController { + @Resource + private IInfoService infoService; + @Resource + private IInfoCategoryService infoCategoryService; + + /** + * 查询资讯信息列表 + */ + @PreAuthorize("@ss.hasPermi('manage:info:list')") + @GetMapping("/list") + public TableDataInfo list(Info info) { + startPage(); + List list = infoService.selectInfoList(info); + return getDataTable(list); + } + + /** + * 导出资讯信息列表 + */ + @PreAuthorize("@ss.hasPermi('manage:info:export')") + @Log(title = "资讯信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, Info info) { + List list = infoService.selectInfoList(info); + ExcelUtil util = new ExcelUtil<>(Info.class); + util.exportExcel(response, list, "资讯信息数据"); + } + + /** + * 获取资讯信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('manage:info:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(infoService.selectInfoById(id)); + } + + /** + * 新增资讯信息 + */ + @PreAuthorize("@ss.hasPermi('manage:info:add')") + @Log(title = "资讯信息", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult add(@RequestBody Info info) { + return toAjax(infoService.insertInfo(info)); + } + + /** + * 修改资讯信息 + */ + @PreAuthorize("@ss.hasPermi('manage:info:edit')") + @Log(title = "资讯信息", businessType = BusinessType.UPDATE) + @PutMapping("/edit") + public AjaxResult edit(@RequestBody Info info) { + return infoService.updateInfo(info); + } + + /** + * 删除资讯信息 + */ + @PreAuthorize("@ss.hasPermi('manage:info:remove')") + @Log(title = "资讯信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return infoService.deleteInfoByIds(ids); + } + + + @Log(title = "图片文件上传", businessType = BusinessType.OTHER) + @PostMapping("/picUpload") + public AjaxResult picUpload(@RequestBody MultipartFile file) { + + return infoService.picUpload(file); + } +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/infocategory/InfoCategoryController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/infocategory/InfoCategoryController.java new file mode 100644 index 00000000..f0aae087 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/infocategory/InfoCategoryController.java @@ -0,0 +1,104 @@ +package com.xinelu.manage.controller.infocategory; + +import java.util.List; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; + +import com.xinelu.common.custominterface.Insert; +import com.xinelu.manage.dto.infocategory.InfoCategoryDTO; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +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.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.xinelu.common.annotation.Log; +import com.xinelu.common.core.controller.BaseController; +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.enums.BusinessType; +import com.xinelu.manage.domain.infocategory.InfoCategory; +import com.xinelu.manage.service.infocategory.IInfoCategoryService; +import com.xinelu.common.utils.poi.ExcelUtil; +import com.xinelu.common.core.page.TableDataInfo; + +/** + * 资讯分类Controller + * + * @author xinelu + * @date 2024-04-11 + */ +@RestController +@RequestMapping("/manage/category") +public class InfoCategoryController extends BaseController { + @Resource + private IInfoCategoryService infoCategoryService; + + /** + * 查询资讯分类列表 + */ + @PreAuthorize("@ss.hasPermi('manage:category:list')") + @GetMapping("/list") + public TableDataInfo list(InfoCategory infoCategory) { + startPage(); + List list = infoCategoryService.selectInfoCategoryList(infoCategory); + return getDataTable(list); + } + + /** + * 导出资讯分类列表 + */ + @PreAuthorize("@ss.hasPermi('manage:category:export')") + @Log(title = "资讯分类", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, InfoCategory infoCategory) { + List list = infoCategoryService.selectInfoCategoryList(infoCategory); + ExcelUtil util = new ExcelUtil<>(InfoCategory.class); + util.exportExcel(response, list, "资讯分类数据"); + } + + /** + * 获取资讯分类详细信息 + */ + @PreAuthorize("@ss.hasPermi('manage:category:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + return AjaxResult.success(infoCategoryService.selectInfoCategoryById(id)); + } + + /** + * 新增资讯分类 + */ + @PreAuthorize("@ss.hasPermi('manage:category:add')") + @Log(title = "资讯分类", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult add(@RequestBody @Validated(Insert.class) InfoCategoryDTO infoCategoryDTO) { + + return infoCategoryService.insertInfoCategory(infoCategoryDTO); + } + + + /** + * 修改资讯分类 + */ + @PreAuthorize("@ss.hasPermi('manage:category:edit')") + @Log(title = "资讯分类", businessType = BusinessType.UPDATE) + @PutMapping("/edit") + public AjaxResult edit(@RequestBody InfoCategory infoCategory) { + return infoCategoryService.updateInfoCategory(infoCategory); + } + + /** + * 删除资讯分类 + */ + @PreAuthorize("@ss.hasPermi('manage:category:remove')") + @Log(title = "资讯分类", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(infoCategoryService.deleteInfoCategoryByIds(ids)); + } +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/info/Info.java b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/info/Info.java new file mode 100644 index 00000000..a1eeede6 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/info/Info.java @@ -0,0 +1,152 @@ +package com.xinelu.manage.domain.info; + +import java.time.LocalDateTime; +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.xinelu.common.annotation.Excel; +import com.xinelu.common.core.domain.BaseEntity; + +/** + * 资讯信息对象 info + * + * @author xinelu + * @date 2024-04-11 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "资讯信息对象", description = "info") +public class Info extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 主键id + */ + private Long id; + + /** + * 资讯所属分类id + */ + @ApiModelProperty(value = "资讯所属分类id") + @Excel(name = "资讯所属分类id") + private Long infoCategoryId; + + + /** + * 资讯所属分类id + */ + @ApiModelProperty(value = "资讯列别名称") + @Excel(name = "资讯类别名称") + private String infoCategoryName; + + /** + * 资讯标题 + */ + @ApiModelProperty(value = "资讯标题") + @Excel(name = "资讯标题") + private String infoTitle; + + /** + * 资讯编码 + */ + @ApiModelProperty(value = "资讯编码") + @Excel(name = "资讯编码") + private String infoCode; + + /** + * 资讯图文内容,富文本 + */ + @ApiModelProperty(value = "资讯图文内容,富文本") + @Excel(name = "资讯图文内容,富文本") + private String infoContent; + + /** + * 咨询点击次数 + */ + @ApiModelProperty(value = "资讯点击次数") + @Excel(name = "咨询点击次数") + private Long infoClickCount; + + /** + * 资讯跳转路径 + */ + @ApiModelProperty(value = "资讯跳转路径") + @Excel(name = "资讯跳转路径") + private String infoJumpLink; + + + /** + * 资讯大图地址 + */ + @ApiModelProperty(value = "资讯大图地址") + @Excel(name = "资讯大图地址") + private String infoLargePictureUrl; + + /** + * 资讯排序 + */ + @ApiModelProperty(value = "资讯排序") + @Excel(name = "资讯排序") + private Long infoSort; + + /** + * 资讯创建人 + */ + @ApiModelProperty(value = "资讯创建人") + @Excel(name = "资讯创建人") + private String infoCreator; + + /** + * 资讯创建时间 + */ + @ApiModelProperty(value = "资讯创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "资讯创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime infoCreateTime; + + /** + * 资讯修改人 + */ + @ApiModelProperty(value = "资讯修改人") + @Excel(name = "资讯修改人") + private String infoReviser; + + /** + * 资讯修改时间 + */ + @ApiModelProperty(value = "资讯修改时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "资讯修改时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime infoModifyTime; + + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("infoCategoryId", getInfoCategoryId()) + .append("infoCategoryName", getInfoCategoryName()) + .append("infoTitle", getInfoTitle()) + .append("infoCode", getInfoCode()) + .append("infoContent", getInfoContent()) + .append("infoClickCount", getInfoClickCount()) + .append("infoJumpLink", getInfoJumpLink()) + .append("infoLargePictureUrl", getInfoLargePictureUrl()) + .append("infoSort", getInfoSort()) + .append("infoCreator", getInfoCreator()) + .append("infoCreateTime", getInfoCreateTime()) + .append("infoReviser", getInfoReviser()) + .append("infoModifyTime", getInfoModifyTime()) + .toString(); + } +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/infocategory/InfoCategory.java b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/infocategory/InfoCategory.java new file mode 100644 index 00000000..1e1b0bfa --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/infocategory/InfoCategory.java @@ -0,0 +1,81 @@ +package com.xinelu.manage.domain.infocategory; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.xinelu.common.annotation.Excel; +import com.xinelu.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.time.LocalDateTime; +import java.util.Date; + +/** + * 资讯分类对象 info_category + * + * @author xinelu + * @date 2024-04-11 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "资讯分类对象", description = "info_category") +public class InfoCategory extends BaseEntity + { +private static final long serialVersionUID=1L; + + /** 主键id */ + private Long id; + + /** 资讯分类编码 */ + @ApiModelProperty(value = "资讯分类编码") + @Excel(name = "资讯分类编码") + private String infoCategoryCode; + + /** 资讯分类名称 */ + @ApiModelProperty(value = "资讯分类名称") + @Excel(name = "资讯分类名称") + private String infoCategoryName; + + /** 资讯分类类型 */ + @ApiModelProperty(value = "资讯分类类型") + @Excel(name = "资讯分类类型") + private String infoCategoryType; + + /** 资讯分类排序 */ + @ApiModelProperty(value = "资讯分类排序") + @Excel(name = "资讯分类排序") + private Long infoCategorySort; + + /** 资讯创建人 */ + @ApiModelProperty(value = "资讯创建人") + @Excel(name = "资讯创建人") + private String infoCategoryCreator; + + /** 资讯创建时间 */ + @ApiModelProperty(value = "资讯创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "资讯创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime infoCategoryCreateTime; + + + +@Override +public String toString(){ + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id",getId()) + .append("infoCategoryCode",getInfoCategoryCode()) + .append("infoCategoryName",getInfoCategoryName()) + .append("infoCategoryType",getInfoCategoryType()) + .append("infoCategorySort",getInfoCategorySort()) + .append("infoCategoryCreator",getInfoCategoryCreator()) + .append("infoCategoryCreateTime",getInfoCategoryCreateTime()) + .toString(); + } + } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/infocategory/InfoCategoryDTO.java b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/infocategory/InfoCategoryDTO.java new file mode 100644 index 00000000..7a70443b --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/infocategory/InfoCategoryDTO.java @@ -0,0 +1,17 @@ +package com.xinelu.manage.dto.infocategory; + +import com.xinelu.manage.domain.infocategory.InfoCategory; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class InfoCategoryDTO implements Serializable { + + + /** + * 资讯分类对象传入集合 + */ + private List infoCategoryList; +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/info/InfoMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/info/InfoMapper.java new file mode 100644 index 00000000..300f80de --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/info/InfoMapper.java @@ -0,0 +1,72 @@ +package com.xinelu.manage.mapper.info; + +import java.util.List; + +import com.xinelu.manage.domain.info.Info; + +/** + * 资讯信息Mapper接口 + * + * @author xinelu + * @date 2024-04-11 + */ +public interface InfoMapper { + /** + * 查询资讯信息 + * + * @param id 资讯信息主键 + * @return 资讯信息 + */ + Info selectInfoById(Long id); + + /** + * 查询资讯信息列表 + * + * @param info 资讯信息 + * @return 资讯信息集合 + */ + List selectInfoList(Info info); + + /** + * 新增资讯信息 + * + * @param info 资讯信息 + * @return 结果 + */ + int insertInfo(Info info); + + /** + * 修改资讯信息 + * + * @param info 资讯信息 + * @return 结果 + */ + int updateInfo(Info info); + + /** + * 删除资讯信息 + * + * @param id 资讯信息主键 + * @return 结果 + */ + int deleteInfoById(Long id); + + /** + * 批量删除资讯信息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteInfoByIds(Long[] ids); + + + /** + * 根据id数组查询资讯信息 + * + * @param ids 数组 + * @return List + */ + + List selectInfoByIds(Long[] ids); + +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/infocategory/InfoCategoryMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/infocategory/InfoCategoryMapper.java new file mode 100644 index 00000000..d70e3fb8 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/infocategory/InfoCategoryMapper.java @@ -0,0 +1,94 @@ +package com.xinelu.manage.mapper.infocategory; + +import java.util.List; + +import com.xinelu.manage.domain.infocategory.InfoCategory; + +/** + * 资讯分类Mapper接口 + * + * @author xinelu + * @date 2024-04-11 + */ +public interface InfoCategoryMapper { + /** + * 查询资讯分类 + * + * @param id 资讯分类主键 + * @return 资讯分类 + */ + InfoCategory selectInfoCategoryById(Long id); + + /** + * 根据名称查询是否存在类型 + * @param name + * @return + */ + InfoCategory selectInfoCategoryByName(String name); + + /** + * 查询资讯分类列表 + * + * @param infoCategory 资讯分类 + * @return 资讯分类集合 + */ + List selectInfoCategoryList(InfoCategory infoCategory); + + /** + * 新增资讯分类 + * + * @param infoCategory 资讯分类 + * @return 结果 + */ + int insertInfoCategory(InfoCategory infoCategory); + + /** + * 修改资讯分类 + * + * @param infoCategory 资讯分类 + * @return 结果 + */ + int updateInfoCategory(InfoCategory infoCategory); + + /** + * 删除资讯分类 + * + * @param id 资讯分类主键 + * @return 结果 + */ + int deleteInfoCategoryById(Long id); + + /** + * 批量删除资讯分类 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteInfoCategoryByIds(Long[] ids); + + + /** + * 根据分类名称查询重复分类名称 + * + * @param categoryNameList 资讯分类名称集合 + * @return List + */ + List selectInfoCategoryName(List categoryNameList); + + + /** + * 批量新增资讯分类 + * + * @param infoCategoryList 资讯分类集合 + * @return 数量 + */ + int insertInfoCategoryList(List infoCategoryList); + + /** + * 根据分类名称查询重复分类名称 + * + * @param infoCategoryName 资讯分类名称 + * @return int + **/ + int selectInfoCategoryCount(String infoCategoryName); +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/info/IInfoService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/info/IInfoService.java new file mode 100644 index 00000000..d3e80085 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/info/IInfoService.java @@ -0,0 +1,70 @@ +package com.xinelu.manage.service.info; + +import java.util.List; + +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.manage.domain.info.Info; +import org.springframework.web.multipart.MultipartFile; + +/** + * 资讯信息Service接口 + * + * @author xinelu + * @date 2024-04-11 + */ +public interface IInfoService { + /** + * 查询资讯信息 + * + * @param id 资讯信息主键 + * @return 资讯信息 + */ + Info selectInfoById(Long id); + + /** + * 查询资讯信息列表 + * + * @param info 资讯信息 + * @return 资讯信息集合 + */ + List selectInfoList(Info info); + + /** + * 新增资讯信息 + * + * @param info 资讯信息 + * @return 结果 + */ + int insertInfo(Info info); + + /** + * 修改资讯信息 + * + * @param info 资讯信息 + * @return 结果 + */ + AjaxResult updateInfo(Info info); + + /** + * 批量删除资讯信息 + * + * @param ids 需要删除的资讯信息主键集合 + * @return 结果 + */ + AjaxResult deleteInfoByIds(Long[] ids); + + /** + * 删除资讯信息信息 + * + * @param id 资讯信息主键 + * @return 结果 + */ + int deleteInfoById(Long id); + + /** + * 图片文件上传 + * @param file + * @return + */ + AjaxResult picUpload(MultipartFile file); +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/info/impl/InfoServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/info/impl/InfoServiceImpl.java new file mode 100644 index 00000000..6704c2f1 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/info/impl/InfoServiceImpl.java @@ -0,0 +1,225 @@ +package com.xinelu.manage.service.info.impl; + +import java.io.File; +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import com.xinelu.common.config.SystemBusinessConfig; +import com.xinelu.common.constant.Constants; +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.exception.ServiceException; +import com.xinelu.common.utils.SecurityUtils; +import com.xinelu.common.utils.codes.GenerateSystemCodeUtil; +import com.xinelu.common.utils.file.FileUploadUtils; +import com.xinelu.common.utils.file.FileUtils; +import io.netty.util.internal.ObjectUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xinelu.manage.mapper.info.InfoMapper; +import com.xinelu.manage.domain.info.Info; +import com.xinelu.manage.service.info.IInfoService; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; + +/** + * 资讯信息Service业务层处理 + * + * @author xinelu + * @date 2024-04-11 + */ +@Service +public class InfoServiceImpl implements IInfoService { + @Resource + private InfoMapper infoMapper; + @Resource + private GenerateSystemCodeUtil generateSystemCodeUtil; + @Resource + private SystemBusinessConfig systemBusinessConfig; + + /** + * 查询资讯信息 + * + * @param id 资讯信息主键 + * @return 资讯信息 + */ + @Override + public Info selectInfoById(Long id) { + return infoMapper.selectInfoById(id); + } + + /** + * 查询资讯信息列表 + * + * @param info 资讯信息 + * @return 资讯信息 + */ + @Override + public List selectInfoList(Info info) { + return infoMapper.selectInfoList(info); + } + + /** + * 新增资讯信息 + * + * @param info 资讯信息 + * @return 结果 + */ + @Override + public int insertInfo(Info info) { + info.setInfoCreateTime(LocalDateTime.now()); + info.setInfoCreator(SecurityUtils.getUsername()); + info.setInfoCode(Constants.INFO_CODE + generateSystemCodeUtil.generateSystemCode(Constants.INFO_CODE)); + return infoMapper.insertInfo(info); + } + + /** + * 修改资讯信息 + * + * @param info 资讯信息 + * @return 结果 + */ + @Override + public AjaxResult updateInfo(Info info) { + //根据id查询之前的数据 + Info infoByID = infoMapper.selectInfoById(info.getId()); + if (Objects.isNull(infoByID)) { + return AjaxResult.error("当前资讯信息不存在,无法修改,请联系管理员!"); + } + + //添加修改人 修改时间 + info.setInfoReviser(SecurityUtils.getUsername()); + info.setInfoModifyTime(LocalDateTime.now()); + int count = infoMapper.updateInfo(info); + if (count <= 0) { + throw new ServiceException("修改资讯信息失败,请联系管理员!"); + } + + //如果两个图片不相等,删除之前的图片 + if (!info.getInfoLargePictureUrl().equals(infoByID.getInfoLargePictureUrl())) { + deletePictureUrl(infoByID.getInfoLargePictureUrl()); + } + + //遍历修改前后内容相不相等,如果不为空且不相等,寻找遍历前后图片的差集,然后删除. + if (StringUtils.isNotBlank(info.getInfoContent()) && StringUtils.isNotBlank(infoByID.getInfoContent()) + && !info.getInfoContent().equals(infoByID.getInfoContent())) { + //获取图片地址 + List infoImgSrc = FileUtils.getImgSrc(info.getInfoContent()); + List infoByIDImgSrc = FileUtils.getImgSrc(infoByID.getInfoContent()); + + //遍历删除图片 + List subList = new ArrayList<>(CollectionUtils.subtract(infoImgSrc, infoByIDImgSrc)); + for (String picUrl : subList) { + + if (StringUtils.isBlank(picUrl)) { //删除富文本图片 + continue; + } + //修改路径 + String substring = picUrl.substring(picUrl.indexOf("/profile")); + //删除富文本图片 + deletePictureUrl(substring); + } + + } + return AjaxResult.success(); + } + + /** + * 批量删除资讯信息 + * + * @param ids 需要删除的资讯信息主键 + * @return 结果 + */ + @Override + public AjaxResult deleteInfoByIds(Long[] ids) { + //查询删除之前数据 + List infoList = infoMapper.selectInfoByIds(ids); + //删除表信息 + int count = infoMapper.deleteInfoByIds(ids); + if (count <= 0) { + return AjaxResult.error("删除资讯信息失败!"); + } + + //筛选资讯主缩略图 + List largePicUrlList = infoList.stream().filter(Objects::nonNull).map(Info::getInfoLargePictureUrl).filter(StringUtils::isNotBlank).collect(Collectors.toList()); + //删除主图 + for (String picUrl : largePicUrlList) { + String substring = picUrl.substring(picUrl.indexOf("/profile")); + //删除富文本图片 + deletePictureUrl(substring); + } + + //筛选资讯内容 + List infoContentList = infoList.stream().filter(Objects::nonNull).map(Info::getInfoLargePictureUrl).filter(StringUtils::isNotBlank).collect(Collectors.toList()); + //遍历获取富文本内容图片地址 + for (String infoContent : infoContentList) { + List picUrlList = FileUtils.getImgSrc(infoContent); + for (String picUrl : picUrlList) { + if (StringUtils.isBlank(picUrl)) { + continue; + } + //修改路径 + String substring = picUrl.substring(picUrl.indexOf("/profile")); + //删除富文本图片 + deletePictureUrl(substring); + } + } + + return AjaxResult.success(); + } + + /** + * 删除资讯信息信息 + * + * @param id 资讯信息主键 + * @return 结果 + */ + @Override + public int deleteInfoById(Long id) { + return infoMapper.deleteInfoById(id); + } + + /** + * 图片文件上传 + * + * @param file + * @return + */ + public AjaxResult picUpload(MultipartFile file) { + try { + return AjaxResult.success(FileUploadUtils.upload( + systemBusinessConfig.getProfile() + systemBusinessConfig.getInfoRichTextPictureUrl(), file)); + } catch (IOException e) { + e.printStackTrace(); + return AjaxResult.error(); + } + } + + /** + * 删除资讯站图片地址 + * + * @param pictureUrl 资讯站图片地址 + * @return void 资讯站图片地址 + **/ + private void deletePictureUrl(String pictureUrl) { + if (StringUtils.isBlank(pictureUrl)) { + return; + } + String picture = SystemBusinessConfig.getProfile() + systemBusinessConfig.getInfoRichTextPictureUrl() + pictureUrl.replaceAll("/profile", ""); + File checkReportNameFile = new File(picture); + if (checkReportNameFile.exists()) { + boolean delete = checkReportNameFile.delete(); + if (BooleanUtils.isFalse(delete)) { + throw new ServiceException("图片地址删除失败!"); + } + } + } + +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/infocategory/IInfoCategoryService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/infocategory/IInfoCategoryService.java new file mode 100644 index 00000000..64572f24 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/infocategory/IInfoCategoryService.java @@ -0,0 +1,65 @@ +package com.xinelu.manage.service.infocategory; + +import java.util.List; + +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.manage.domain.infocategory.InfoCategory; +import com.xinelu.manage.dto.infocategory.InfoCategoryDTO; +import org.springframework.web.multipart.MultipartFile; + +/** + * 资讯分类Service接口 + * + * @author xinelu + * @date 2024-04-11 + */ +public interface IInfoCategoryService { + /** + * 查询资讯分类 + * + * @param id 资讯分类主键 + * @return 资讯分类 + */ + InfoCategory selectInfoCategoryById(Long id); + + /** + * 查询资讯分类列表 + * + * @param infoCategory 资讯分类 + * @return 资讯分类集合 + */ + List selectInfoCategoryList(InfoCategory infoCategory); + + /** + * 新增资讯分类 + * + * @param infoCategoryDTO 资讯分类 + * @return 结果 + */ + AjaxResult insertInfoCategory(InfoCategoryDTO infoCategoryDTO); + + /** + * 修改资讯分类 + * + * @param infoCategory 资讯分类 + * @return 结果 + */ + AjaxResult updateInfoCategory(InfoCategory infoCategory); + + /** + * 批量删除资讯分类 + * + * @param ids 需要删除的资讯分类主键集合 + * @return 结果 + */ + int deleteInfoCategoryByIds(Long[] ids); + + /** + * 删除资讯分类信息 + * + * @param id 资讯分类主键 + * @return 结果 + */ + int deleteInfoCategoryById(Long id); + +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/infocategory/impl/InfoCategoryServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/infocategory/impl/InfoCategoryServiceImpl.java new file mode 100644 index 00000000..27fad338 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/infocategory/impl/InfoCategoryServiceImpl.java @@ -0,0 +1,157 @@ +package com.xinelu.manage.service.infocategory.impl; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import com.xinelu.common.constant.Constants; +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.utils.SecurityUtils; +import com.xinelu.common.utils.codes.GenerateSystemCodeUtil; +import com.xinelu.common.utils.file.FileUploadUtils; +import com.xinelu.manage.dto.infocategory.InfoCategoryDTO; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import com.xinelu.manage.mapper.infocategory.InfoCategoryMapper; +import com.xinelu.manage.domain.infocategory.InfoCategory; +import com.xinelu.manage.service.infocategory.IInfoCategoryService; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; + +/** + * 资讯分类Service业务层处理 + * + * @author xinelu + * @date 2024-04-11 + */ +@Service +public class InfoCategoryServiceImpl implements IInfoCategoryService { + @Resource + private InfoCategoryMapper infoCategoryMapper; + + @Resource + private GenerateSystemCodeUtil generateSystemCodeUtil; + + /** + * 查询资讯分类 + * + * @param id 资讯分类主键 + * @return 资讯分类 + */ + @Override + public InfoCategory selectInfoCategoryById(Long id) { + return infoCategoryMapper.selectInfoCategoryById(id); + } + + /** + * 查询资讯分类列表 + * + * @param infoCategory 资讯分类 + * @return 资讯分类 + */ + @Override + public List selectInfoCategoryList(InfoCategory infoCategory) { + return infoCategoryMapper.selectInfoCategoryList(infoCategory); + } + + /** + * 新增资讯分类 + * + * @param infoCategoryDTO 资讯分类 + * @return 结果 + */ + @Override + public AjaxResult insertInfoCategory(InfoCategoryDTO infoCategoryDTO) { + //筛选不为空资讯分类名称 + List categoryNameList = infoCategoryDTO.getInfoCategoryList().stream().filter(Objects::nonNull).map(InfoCategory::getInfoCategoryName).collect(Collectors.toList()); + //资讯分类名称去重 + List distinctNameList = infoCategoryDTO.getInfoCategoryList().stream().filter(Objects::nonNull).map(InfoCategory::getInfoCategoryName).distinct().collect(Collectors.toList()); + + //集合取差集 + List subtractNameList = new ArrayList<>(CollectionUtils.subtract(categoryNameList, distinctNameList)); + if (subtractNameList.size() > 0) { + return AjaxResult.error("'" + subtractNameList.get(0) + "'重复,请修改后重新录入!"); + } + //数据库查询资讯分类名称 + List existCategoryName = infoCategoryMapper.selectInfoCategoryName(categoryNameList); + + List existRetainAllNameList = new ArrayList<>(CollectionUtils.intersection(distinctNameList, existCategoryName)); + if (existRetainAllNameList.size() > 0) { + return AjaxResult.error("'" + existRetainAllNameList.get(0) + "'已存在,请修改后重新录入!"); + } + for (InfoCategory infocategory : infoCategoryDTO.getInfoCategoryList()) { + + infocategory.setCreateTime(LocalDateTime.now());//设置添加时间 + infocategory.setInfoCategoryCreator(SecurityUtils.getUsername());//设置当前的用户 + infocategory.setInfoCategoryType(infocategory.getInfoCategoryName());//类型 无用 直接赋值和名称相同 + infocategory.setInfoCategoryCode(Constants.INFO_CATEGORY_CODE + generateSystemCodeUtil.generateSystemCode(Constants.DEPARTMENT_CODE)); + } + int insertCount = infoCategoryMapper.insertInfoCategoryList(infoCategoryDTO.getInfoCategoryList()); + if (insertCount < 0) { + throw new RuntimeException("新增资讯分类信息失败,请联系管理员!"); + } + return AjaxResult.success(); + } + + /** + * 修改资讯分类 + * + * @param infoCategory 资讯分类 + * @return 结果 + */ + @Override + public AjaxResult updateInfoCategory(InfoCategory infoCategory) { + //根据咨询分类id查询数据库 + // InfoCategory infoCategoryByName = infoCategoryMapper.selectInfoCategoryByName(infoCategory.getInfoCategoryName()); + InfoCategory infoCategoryByName = infoCategoryMapper.selectInfoCategoryById(infoCategory.getId()); + if (Objects.isNull(infoCategoryByName)) { + return AjaxResult.error("当前资讯分类信息不存在,无法修改,请联系管理员!"); + } + //两名称都不为空,且不相等 + if (StringUtils.isNotBlank(infoCategory.getInfoCategoryName()) && StringUtils.isNotBlank(infoCategoryByName.getInfoCategoryName()) && !infoCategory.getInfoCategoryName().equals(infoCategoryByName.getInfoCategoryName())) { + int infoCategoryCount = infoCategoryMapper.selectInfoCategoryCount(infoCategory.getInfoCategoryName());//查找要修改的名称是否已经存在了 + if (infoCategoryCount > 0) { + return AjaxResult.error("已有该资讯分类信息名称:" + infoCategory.getInfoCategoryName()); + } + } + infoCategoryByName.setUpdateTime(LocalDateTime.now());//设置时间 + infoCategoryByName.setInfoCategoryName(infoCategory.getInfoCategoryName());//设置名称为修改的名称 + infoCategoryByName.setInfoCategorySort(infoCategory.getInfoCategorySort());//设置排序 + infoCategoryByName.setUpdateBy(SecurityUtils.getUsername());//设置当前用户 + infoCategoryByName.setInfoCategoryType(infoCategory.getInfoCategoryName());//类型 + int updateInfoCategory = infoCategoryMapper.updateInfoCategory(infoCategoryByName);//更新到数据库 + if (updateInfoCategory < 0) { + return AjaxResult.error("修改资讯分类信息失败,请联系管理员!"); + } + return AjaxResult.success(); + } + + /** + * 批量删除资讯分类 + * + * @param ids 需要删除的资讯分类主键 + * @return 结果 + */ + @Override + public int deleteInfoCategoryByIds(Long[] ids) { + return infoCategoryMapper.deleteInfoCategoryByIds(ids); + } + + /** + * * 删除资讯分类信息 + * + * @param id 资讯分类主键 + * @return 结果 + */ + @Override + public int deleteInfoCategoryById(Long id) { + return infoCategoryMapper.deleteInfoCategoryById(id); + } + + +} diff --git a/postdischarge-manage/src/main/resources/mapper/manage/info/InfoMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/info/InfoMapper.xml new file mode 100644 index 00000000..02a0a808 --- /dev/null +++ b/postdischarge-manage/src/main/resources/mapper/manage/info/InfoMapper.xml @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + select id, + info_category_id, + info_category_name, + info_title, + info_code, + info_content, + info_click_count, + info_jump_link, + info_large_picture_url, + info_sort, + info_creator, + info_create_time, + info_reviser, + info_modify_time + from info + + + + + + + + insert into info + + info_category_id, + + info_category_name, + + info_title, + + info_code, + + info_content, + + info_click_count, + + info_jump_link, + + info_large_picture_url, + + info_sort, + + info_creator, + + info_create_time, + + info_reviser, + + info_modify_time, + + + + #{infoCategoryId}, + + #{infoCategoryName}, + + #{infoTitle}, + + #{infoCode}, + + #{infoContent}, + + #{infoClickCount}, + + #{infoJumpLink}, + + #{infoLargePictureUrl}, + + #{infoSort}, + + #{infoCreator}, + + #{infoCreateTime}, + + #{infoReviser}, + + #{infoModifyTime}, + + + + + + update info + + info_category_id = + #{infoCategoryId}, + + info_category_name = + #{infoCategoryName}, + + info_title = + #{infoTitle}, + + info_code = + #{infoCode}, + + info_content = + #{infoContent}, + + info_click_count = + #{infoClickCount}, + + info_jump_link = + #{infoJumpLink}, + + info_large_picture_url = + #{infoLargePictureUrl}, + + info_sort = + #{infoSort}, + + info_creator = + #{infoCreator}, + + info_create_time = + #{infoCreateTime}, + + info_reviser = + #{infoReviser}, + + info_modify_time = + #{infoModifyTime}, + + + where id = #{id} + + + + delete + from info + where id = #{id} + + + + delete from info where id in + + #{id} + + + + + + \ No newline at end of file diff --git a/postdischarge-manage/src/main/resources/mapper/manage/infocategory/InfoCategoryMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/infocategory/InfoCategoryMapper.xml new file mode 100644 index 00000000..47380baf --- /dev/null +++ b/postdischarge-manage/src/main/resources/mapper/manage/infocategory/InfoCategoryMapper.xml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + select id, info_category_code, info_category_name, info_category_type, info_category_sort, info_category_creator, info_category_create_time from info_category + + + + + + + + + + insert into info_category + + info_category_code, + + info_category_name, + + info_category_type, + + info_category_sort, + + info_category_creator, + + info_category_create_time, + + + + #{infoCategoryCode}, + + #{infoCategoryName}, + + #{infoCategoryType}, + + #{infoCategorySort}, + + #{infoCategoryCreator}, + + #{infoCategoryCreateTime}, + + + + + + update info_category + + info_category_code = + #{infoCategoryCode}, + + info_category_name = + #{infoCategoryName}, + + info_category_type = + #{infoCategoryType}, + + info_category_sort = + #{infoCategorySort}, + + info_category_creator = + #{infoCategoryCreator}, + + info_category_create_time = + #{infoCategoryCreateTime}, + + + where id = #{id} + + + + delete from info_category where id = #{id} + + + + delete from info_category where id in + + #{id} + + + + + + + + + insert into info_category( + info_category_code, + info_category_name, + info_category_type, + info_category_sort, + info_category_creator, + info_category_create_time + )values + + ( + #{infoCategoryList.infoCategoryCode}, + #{infoCategoryList.infoCategoryName}, + #{infoCategoryList.infoCategoryType}, + #{infoCategoryList.infoCategorySort}, + #{infoCategoryList.infoCategoryCreator}, + #{infoCategoryList.infoCategoryCreateTime} + ) + + + + + \ No newline at end of file diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/info/MobileInfoController.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/info/MobileInfoController.java new file mode 100644 index 00000000..c0b309a8 --- /dev/null +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/info/MobileInfoController.java @@ -0,0 +1,39 @@ +package com.xinelu.mobile.controller.info; + +import com.xinelu.common.core.controller.BaseController; +import com.xinelu.common.core.page.TableDataInfo; +import com.xinelu.manage.domain.info.Info; +import com.xinelu.manage.service.info.IInfoService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; +import java.util.List; + +import static com.xinelu.common.utils.PageUtils.startPage; + +/** + * 微信端获取资讯信息 + * 资讯信息Controller + */ +@Slf4j +@RestController +@RequestMapping("/mobile/info") +public class MobileInfoController extends BaseController { + + + @Resource + private IInfoService infoService; + + + //@PreAuthorize("@ss.hasPermi('mobile:info:list')") + @GetMapping("/list") + public TableDataInfo list(Info info) { + startPage(); + List list = infoService.selectInfoList(info); + return getDataTable(list); + } + +} From 9e73d21565a024c247e2935bc39768aca4b2c30c Mon Sep 17 00:00:00 2001 From: gognqingkai <1825346742@qq.com> Date: Tue, 16 Apr 2024 15:37:05 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=B5=84=E8=AE=AF=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E8=B5=84=E8=AE=AF=E4=BF=A1=E6=81=AF=E5=92=8C=E8=B5=84=E8=AE=AF?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=AE=9E=E7=8E=B0=20add=20by=20gqk=202024/04?= =?UTF-8?q?/16=2015:29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xinelu/common/constant/Constants.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java index 9ae03f9a..0102e27c 100644 --- a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java +++ b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java @@ -283,4 +283,34 @@ public class Constants { * 成功 */ public static final int SUCCESS_ERROR_CODE = 0; + + /** + * 院后微信小程序登录接口地址 + */ + public static final String APPLET_LOGIN_URL = "https://api.weixin.qq.com/sns/jscode2session"; + + /** + * 微信小程序ACCESS_TOKEN前缀 + */ + public static final String POST_DISCHARGE_APPLET_ACCESS_TOKEN = "POST_Discharge_APPLET_ACCESS_TOKEN_"; + + /** + * 返回成功状态码 + */ + public static final int SUCCESS_CODE = 0; + + /** + * 院后微信小程序获取用户手机号接口地址 + */ + public static final String PHONE_NUMBER_URL = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token="; + + /** + * 获取微信小程序access_token错误码 + */ + public static final int ERROR_ACCESS_CODE = 40001; + + /** + * 返回成功状态码 + */ + public static final String OK = "ok"; } From 8a132c21d3dd8ed183357f8d36f12911bef1585f Mon Sep 17 00:00:00 2001 From: gognqingkai <1825346742@qq.com> Date: Tue, 16 Apr 2024 15:43:18 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=B5=84=E8=AE=AF=E5=AF=8C=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E9=85=8D=E7=BD=AE=EF=BC=8C=E7=BC=96=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=80=9A=E7=94=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 4 +++- .../com/xinelu/common/constant/Constants.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/postdischarge-admin/src/main/resources/application.yml b/postdischarge-admin/src/main/resources/application.yml index c6131886..a6da37a7 100644 --- a/postdischarge-admin/src/main/resources/application.yml +++ b/postdischarge-admin/src/main/resources/application.yml @@ -26,6 +26,8 @@ xinelu: script-file-url: /scriptFileUrl # 获取管理端富文本的上传路径 rich-text-picture-url: /richTextPictureUrl + # 资讯富文本的上传路径 + info-rich-text-picture-url: /infoRichTextPictureUrl # 开发环境配置 server: @@ -103,7 +105,7 @@ token: # 令牌有效期(默认30分钟) expireTime: 30 # 请求拦截白名单 - ant-matchers: /postDischarge/**,/testMobile/** + ant-matchers: /postDischarge/**,/testMobile/**,/postDischargeApplet/** ## MyBatis-Plus配置 mybatis-plus: diff --git a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java index 0102e27c..e7d20390 100644 --- a/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java +++ b/postdischarge-common/src/main/java/com/xinelu/common/constant/Constants.java @@ -313,4 +313,19 @@ public class Constants { * 返回成功状态码 */ public static final String OK = "ok"; + + /** + * 资讯分类编码前缀 + */ + public static final String INFO_CATEGORY_CODE = "ICC"; + + /** + * 资讯编码前缀 + */ + public static final String INFO_CODE = "IC"; + + /** + * 科室编码前缀 + */ + public static final String DEPARTMENT_CODE = "HDC"; } From c7e7425ba5fdbd32ed0164224223f24476cd9f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=AA=E5=AF=92?= <2533659732@qq.com> Date: Wed, 17 Apr 2024 11:22:45 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppletPersonCenterController.java | 5 +++++ .../AppletPersonCenterMapper.java | 18 ++++++++++++++++++ .../mapper/mobiletest/MobileTestMapper.java | 10 ---------- .../AppletPersonCenterService.java | 2 ++ .../Impl/AppletPersonCenterServiceImpl.java | 8 ++++++++ .../AppletPersonCenterMapper.xml | 10 ++++++++++ .../mapper/mobile/mobiletest/MobileTestMapper | 6 ------ 7 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/appletpersoncenter/AppletPersonCenterMapper.java delete mode 100644 postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/mobiletest/MobileTestMapper.java create mode 100644 postdischarge-mobile/src/main/resources/mapper/appletpersoncenter/AppletPersonCenterMapper.xml delete mode 100644 postdischarge-mobile/src/main/resources/mapper/mobile/mobiletest/MobileTestMapper diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java index 2bf9b0de..6cc0709b 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/controller/appletpersoncenter/AppletPersonCenterController.java @@ -51,4 +51,9 @@ public class AppletPersonCenterController { public AjaxResult getResidentInfoById(Long residentId) { return appletPersonCenterService.getResidentInfoById(residentId); } + + @GetMapping("/test") + public void test() { + appletPersonCenterService.test(); + } } diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/appletpersoncenter/AppletPersonCenterMapper.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/appletpersoncenter/AppletPersonCenterMapper.java new file mode 100644 index 00000000..b4d7d82b --- /dev/null +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/appletpersoncenter/AppletPersonCenterMapper.java @@ -0,0 +1,18 @@ +package com.xinelu.mobile.mapper.appletpersoncenter; + +import com.xinelu.manage.domain.residentinfo.ResidentInfo; + +/** + * @Description 院后小程序个人中心Mapper层 + * @Author 纪寒 + * @Date 2024-04-16 10:49:14 + * @Version 1.0 + */ +public interface AppletPersonCenterMapper { + /** + * 查询居民信息 + * + * @return 居民信息 + */ + ResidentInfo selectResidentInfoTwo(); +} diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/mobiletest/MobileTestMapper.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/mobiletest/MobileTestMapper.java deleted file mode 100644 index 5307ed69..00000000 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/mapper/mobiletest/MobileTestMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.xinelu.mobile.mapper.mobiletest; - -/** - * @Description 测试 Mapper - * @Author 纪寒 - * @Date 2024-02-18 16:59:30 - * @Version 1.0 - */ -public interface MobileTestMapper { -} diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java index 2a4dc85f..35f29739 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/AppletPersonCenterService.java @@ -26,4 +26,6 @@ public interface AppletPersonCenterService { * @return 个人信息 */ AjaxResult getResidentInfoById(Long residentId); + + void test(); } diff --git a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java index 8fe5f36e..a786c96d 100644 --- a/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java +++ b/postdischarge-mobile/src/main/java/com/xinelu/mobile/service/appletpersoncenter/Impl/AppletPersonCenterServiceImpl.java @@ -5,6 +5,7 @@ import com.xinelu.common.constant.Constants; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.manage.domain.residentinfo.ResidentInfo; import com.xinelu.manage.mapper.residentinfo.ResidentInfoMapper; +import com.xinelu.mobile.mapper.appletpersoncenter.AppletPersonCenterMapper; import com.xinelu.mobile.service.appletpersoncenter.AppletPersonCenterService; import com.xinelu.mobile.utils.WeChatAppletUtils; import com.xinelu.mobile.vo.appletpersoncenter.PostDischargeAppletPhoneVO; @@ -36,6 +37,8 @@ public class AppletPersonCenterServiceImpl implements AppletPersonCenterService private RedisTemplate redisTemplate; @Resource private ResidentInfoMapper residentInfoMapper; + @Resource + private AppletPersonCenterMapper appletPersonCenterMapper; /** * 院后微信小程序一键登录接口 @@ -120,4 +123,9 @@ public class AppletPersonCenterServiceImpl implements AppletPersonCenterService public AjaxResult getResidentInfoById(Long residentId) { return AjaxResult.success(residentInfoMapper.selectResidentInfoById(residentId)); } + + @Override + public void test() { + appletPersonCenterMapper.selectResidentInfoTwo(); + } } diff --git a/postdischarge-mobile/src/main/resources/mapper/appletpersoncenter/AppletPersonCenterMapper.xml b/postdischarge-mobile/src/main/resources/mapper/appletpersoncenter/AppletPersonCenterMapper.xml new file mode 100644 index 00000000..6173a661 --- /dev/null +++ b/postdischarge-mobile/src/main/resources/mapper/appletpersoncenter/AppletPersonCenterMapper.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/postdischarge-mobile/src/main/resources/mapper/mobile/mobiletest/MobileTestMapper b/postdischarge-mobile/src/main/resources/mapper/mobile/mobiletest/MobileTestMapper deleted file mode 100644 index 3b8ea21e..00000000 --- a/postdischarge-mobile/src/main/resources/mapper/mobile/mobiletest/MobileTestMapper +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file