| | |
| | | // strategy.setTablePrefix(pc.getModuleName() + ""); |
| | | // strategy.setLikeTable(new LikeTable("room")); |
| | | //strategy.setLikeTable(new LikeTable("member")); |
| | | strategy.setLikeTable(new LikeTable("t_sys_obs_config"));// 生成表名 |
| | | strategy.setLikeTable(new LikeTable("t_sys_ai_config"));// 生成表名 |
| | | // strategy.setLikeTable(new LikeTable("t_hotel"));// 生成表名 |
| | | // strategy.setLikeTable(new LikeTable("t_scan_message"));// 生成表名 |
| | | // strategy.setNotLikeTable(new LikeTable("hotel_info"));// 不生成表名 |
New file |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * <p> |
| | | * AI应用配置 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author xiaochen |
| | | * @since 2025-09-17 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/t-sys-ai-config") |
| | | public class TSysAiConfigController { |
| | | |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiOperation(value = "获取用户列表") |
| | | @PostMapping("/list") |
| | | @PreAuthorize("@ss.hasPermi('system:user')") |
| | | // @PreAuthorize("@ss.hasPermi('system:user')") |
| | | public AjaxResult list(@RequestBody SysUserQuery query) |
| | | { |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | |
| | | |
| | | @ApiOperation(value = "获取用户列表-不分页") |
| | | @PostMapping("/listNotPage") |
| | | @PreAuthorize("@ss.hasPermi('system:user')") |
| | | |
| | | // @PreAuthorize("@ss.hasPermi('system:user')") |
| | | public AjaxResult listNotPage() |
| | | { |
| | | List<SysUser> list = userService.selectList(); |
| | |
| | | //import com.ruoyi.system.mapper.SysRoleMenuMapper; |
| | | //import com.ruoyi.system.service.ISysMenuService; |
| | | //import com.ruoyi.system.service.ISysRoleService; |
| | | //import com.ruoyi.system.utils.util.H5AIUtil; |
| | | //import com.tencentcloudapi.cws.v20180312.models.Site; |
| | | //import lombok.extern.slf4j.Slf4j; |
| | | //import org.junit.jupiter.api.Test; |
| | |
| | | // roleMenuMapper.batchRoleMenu(sysRoleMenus2); |
| | | // |
| | | // } |
| | | // @Autowired |
| | | // private H5AIUtil h5AIUtil; |
| | | // @Test |
| | | // public void test(){ |
| | | // String accessToken = h5AIUtil.getAccessToken(); |
| | | // System.err.println(accessToken); |
| | | // } |
| | | // |
| | | //} |
New file |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.framework.web.service.SysLoginService; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.TSysAiConfig; |
| | | import com.ruoyi.system.service.TSysAiConfigService; |
| | | import com.ruoyi.system.service.TSysAppUserService; |
| | | import com.ruoyi.system.utils.util.AesSimpleUtil; |
| | | import com.ruoyi.system.utils.util.RsaSimpleUtil; |
| | | import com.ruoyi.system.utils.wx.model.WeixinProperties; |
| | | import com.ruoyi.system.utils.wx.tools.WxAppletTools; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * <p> |
| | | * 微信小程序登录 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author xiaochen |
| | | * @since 2024-08-06 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/aiCallback") |
| | | public class H5AICallbackController { |
| | | |
| | | @Autowired |
| | | private TSysAiConfigService sysAiConfigService; |
| | | |
| | | @PostMapping("/reportReturn") |
| | | public String reportReturn(String encryptedJson, String signEncryptedJson) throws Exception { |
| | | TSysAiConfig sysAiConfig = sysAiConfigService.getById(1); |
| | | // 应用AES秘钥 |
| | | String aesKey = sysAiConfig.getAesKey(); |
| | | // 平台RSA公钥 |
| | | String rsaPublicKey = sysAiConfig.getRsaPublicKey(); |
| | | |
| | | // 1. 先解密 |
| | | String source = AesSimpleUtil.decrypt(encryptedJson, aesKey); |
| | | JSONObject jsonObject = JSONObject.parseObject(source); |
| | | |
| | | // 2. 再验证签名 |
| | | String signSource = String.format("%s_%s", |
| | | jsonObject.getString("thirdId"), |
| | | jsonObject.getString("time")); |
| | | boolean verify = RsaSimpleUtil.verify(signSource, signEncryptedJson, rsaPublicKey); |
| | | if (!verify) { |
| | | return "error"; |
| | | } |
| | | // 3. 验证成功,则仅仅业务保存并返回success字符串 |
| | | return "success"; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * <p> |
| | | * AI应用配置 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author xiaochen |
| | | * @since 2025-09-17 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/t-sys-ai-config") |
| | | public class TSysAiConfigController { |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.TSysInspection; |
| | | import com.ruoyi.system.query.TSysInspectionQuery; |
| | | import com.ruoyi.system.service.TSysInspectionService; |
| | | import com.ruoyi.system.vo.TSysInspectionVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 用户检测信息 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author xiaochen |
| | | * @since 2025-08-20 |
| | | */ |
| | | @Api(tags = "用户检测信息管理") |
| | | @RestController |
| | | @RequestMapping("/t-sys-inspection") |
| | | public class TSysInspectionController { |
| | | |
| | | private final TSysInspectionService sysInspectionService; |
| | | private final TokenService tokenService; |
| | | @Autowired |
| | | public TSysInspectionController(TSysInspectionService sysInspectionService, TokenService tokenService) { |
| | | this.sysInspectionService = sysInspectionService; |
| | | this.tokenService = tokenService; |
| | | } |
| | | |
| | | /** |
| | | * 获取用户检测信息管理管理列表 |
| | | */ |
| | | @ApiOperation(value = "获取用户检测信息管理分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<TSysInspectionVO>> pageList(@RequestBody TSysInspectionQuery query) { |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | query.setAppUserId(userId); |
| | | return R.ok(sysInspectionService.pageList(query)); |
| | | } |
| | | /** |
| | | * 查看用户检测信息管理详情 |
| | | */ |
| | | @ApiOperation(value = "查看用户检测信息管理详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public R<TSysInspection> getDetailById(@RequestParam String id) { |
| | | return R.ok(sysInspectionService.getById(id)); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.TSysUserResp; |
| | | import com.ruoyi.common.core.domain.model.LoginBody; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUserApplet; |
| | | import com.ruoyi.common.core.utils.HttpUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.framework.web.service.SysLoginService; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.TSysAppUser; |
| | | import com.ruoyi.system.service.TSysAppUserService; |
| | | import com.ruoyi.system.utils.wx.body.resp.Code2SessionRespBody; |
| | | import com.ruoyi.system.utils.wx.body.resq.Code2SessionResqBody; |
| | | import com.ruoyi.system.utils.wx.model.WeixinProperties; |
| | | import com.ruoyi.system.utils.wx.pojo.AppletUserDecodeData; |
| | | import com.ruoyi.system.utils.wx.pojo.AppletUserEncrypteData; |
| | | import com.ruoyi.system.utils.wx.tools.WxAppletTools; |
| | | import com.ruoyi.system.utils.wx.tools.WxUtils; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * 直播推送 |
| | | */ |
| | | public static final String LIVE_APPOINTMENT_PUSH = "live:appointmentPush:"; |
| | | /** |
| | | * 直播推送 |
| | | */ |
| | | public static final String H5AI_ACCESS_TOKEN = "h5ai_accessToken:"; |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.system.model.TSysAiConfig; |
| | | |
| | | /** |
| | | * <p> |
| | | * AI应用配置 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author xiaochen |
| | | * @since 2025-09-17 |
| | | */ |
| | | public interface TSysAiConfigMapper extends BaseMapper<TSysAiConfig> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.system.model.TSysInspection; |
| | | import com.ruoyi.system.query.TSysInspectionQuery; |
| | | import com.ruoyi.system.vo.TSysInspectionVO; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface TSysInspectionMapper extends BaseMapper<TSysInspection> { |
| | | |
| | | /** |
| | | * 获取用户检测信息管理分页列表 |
| | | * |
| | | * @param query 查询参数 |
| | | * @return List<TSysInspectionVO> |
| | | */ |
| | | List<TSysInspectionVO> pageList(@Param("query") TSysInspectionQuery query, @Param("pageInfo")PageInfo<TSysInspectionVO> pageInfo); |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * AI应用配置 |
| | | * </p> |
| | | * |
| | | * @author xiaochen |
| | | * @since 2025-09-17 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @TableName("t_sys_ai_config") |
| | | @ApiModel(value="TSysAiConfig对象", description="AI应用配置") |
| | | public class TSysAiConfig implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "应用ID") |
| | | @TableField("devId") |
| | | private String devId; |
| | | |
| | | @ApiModelProperty(value = "应用秘钥") |
| | | @TableField("devSecret") |
| | | private String devSecret; |
| | | |
| | | @ApiModelProperty(value = "应用RSA公钥") |
| | | @TableField("devRsaPublicKey") |
| | | private String devRsaPublicKey; |
| | | |
| | | @ApiModelProperty(value = "平台RSA公钥") |
| | | @TableField("rsaPublicKey") |
| | | private String rsaPublicKey; |
| | | |
| | | @ApiModelProperty(value = "应用aesKey") |
| | | @TableField("aesKey") |
| | | private String aesKey; |
| | | |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "风险疾病名称") |
| | | @TableField("disease_risks") |
| | | private String diseaseRisks; |
| | | |
| | | @ApiModelProperty(value = "是否已支付 1=是 0=否") |
| | | @TableField("is_pay") |
| | | private Integer isPay; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.query; |
| | | |
| | | import com.ruoyi.common.core.domain.BasePage; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel(value = "用户检测信息管理查询参数query") |
| | | public class TSysInspectionQuery extends BasePage { |
| | | |
| | | @ApiModelProperty(value = "用户id") |
| | | private String appUserId; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.system.model.TSysAiConfig; |
| | | |
| | | /** |
| | | * <p> |
| | | * AI应用配置 服务类 |
| | | * </p> |
| | | * |
| | | * @author xiaochen |
| | | * @since 2025-09-17 |
| | | */ |
| | | public interface TSysAiConfigService extends IService<TSysAiConfig> { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.system.model.TSysInspection; |
| | | import com.ruoyi.system.query.TSysInspectionQuery; |
| | | import com.ruoyi.system.vo.TSysInspectionVO; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface TSysInspectionService extends IService<TSysInspection> { |
| | | |
| | | /** |
| | | * 获取用户检测信息分页列表 |
| | | * |
| | | * @param query 查询参数 |
| | | * @return PageInfo<TSysInspection> |
| | | */ |
| | | PageInfo<TSysInspectionVO> pageList(TSysInspectionQuery query); |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.mapper.TSysAiConfigMapper; |
| | | import com.ruoyi.system.model.TSysAiConfig; |
| | | import com.ruoyi.system.service.TSysAiConfigService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * AI应用配置 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author xiaochen |
| | | * @since 2025-09-17 |
| | | */ |
| | | @Service |
| | | public class TSysAiConfigServiceImpl extends ServiceImpl<TSysAiConfigMapper, TSysAiConfig> implements TSysAiConfigService { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.system.mapper.TCrmClinicMapper; |
| | | import com.ruoyi.system.model.TCrmClinic; |
| | | import com.ruoyi.system.model.TSysInspection; |
| | | import com.ruoyi.system.mapper.TSysInspectionMapper; |
| | | import com.ruoyi.system.query.TSysInspectionQuery; |
| | | import com.ruoyi.system.service.TSysInspectionService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.vo.SysOperLogVO; |
| | | import com.ruoyi.system.vo.TSysInspectionVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class TSysInspectionServiceImpl extends ServiceImpl<TSysInspectionMapper, TSysInspection> implements TSysInspectionService { |
| | | |
| | | @Autowired |
| | | private TCrmClinicMapper crmClinicMapper; |
| | | |
| | | @Override |
| | | public PageInfo<TSysInspectionVO> pageList(TSysInspectionQuery query) { |
| | | PageInfo<TSysInspectionVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TSysInspectionVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return pageInfo; |
| | | } |
| | | List<String> clinicId = list.stream().map(TSysInspectionVO::getClinicId).collect(Collectors.toList()); |
| | | List<TCrmClinic> crmClinics = crmClinicMapper.selectList(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .in(TCrmClinic::getId, clinicId)); |
| | | for (TSysInspectionVO tSysInspectionVO : list) { |
| | | crmClinics.stream().filter(t -> t.getId().equals(tSysInspectionVO.getClinicId())).findFirst().ifPresent(t -> tSysInspectionVO.setClinicName(t.getClinicName())); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.utils.util; |
| | | |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Base64; |
| | | |
| | | /** |
| | | * aes工具类 |
| | | * |
| | | * @author xuwenbing |
| | | * @date 2019-06-12 |
| | | */ |
| | | public class AesSimpleUtil { |
| | | // 对于Java中AES的默认模式是:AES/ECB/PKCS5Padding |
| | | private static final String AES = "AES"; |
| | | |
| | | /** |
| | | * 加密 |
| | | * |
| | | * @param source 源字符串 |
| | | * @param keyBase64 keyBase64 |
| | | * @return 加密的字符串 |
| | | * @throws Exception |
| | | */ |
| | | public static String encrypt(String source, String keyBase64) throws Exception { |
| | | // 获取secretKey |
| | | byte[] keyBytes = Base64.getDecoder().decode(keyBase64.getBytes(StandardCharsets.UTF_8)); |
| | | SecretKeySpec secretKey = new SecretKeySpec(keyBytes, AES); |
| | | // 数据加密 |
| | | Cipher cipher = Cipher.getInstance(AES); |
| | | cipher.init(Cipher.ENCRYPT_MODE, secretKey); |
| | | byte[] encryptBytes = cipher.doFinal(source.getBytes(StandardCharsets.UTF_8)); |
| | | return Base64.getEncoder().encodeToString(encryptBytes); |
| | | } |
| | | |
| | | /** |
| | | * 解密 |
| | | * |
| | | * @param encrypted 加密的字符串 |
| | | * @param keyBase64 keyBase64 |
| | | * @return 源字符串 |
| | | * @throws Exception |
| | | */ |
| | | public static String decrypt(String encrypted, String keyBase64) throws Exception { |
| | | // 获取secretKey |
| | | byte[] keyBytes = Base64.getDecoder().decode(keyBase64.getBytes(StandardCharsets.UTF_8)); |
| | | SecretKeySpec secretKey = new SecretKeySpec(keyBytes, AES); |
| | | // 数据解密 |
| | | Cipher cipher = Cipher.getInstance(AES); |
| | | cipher.init(Cipher.DECRYPT_MODE, secretKey); |
| | | byte[] decryptBytes = cipher.doFinal(Base64.getDecoder().decode(encrypted)); |
| | | return new String(decryptBytes, StandardCharsets.UTF_8); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.utils.util; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.system.model.TSysAiConfig; |
| | | import com.ruoyi.system.service.TSysAiConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class H5AIUtil { |
| | | |
| | | @Autowired |
| | | private TSysAiConfigService sysAiConfigService; |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | public static final String H5_AI_URL = "https://www.ai-tongue.com/backend/auth/invoker/pwd/signin"; |
| | | |
| | | public String getAccessToken() { |
| | | String accessToken = redisCache.getCacheObject(Constants.H5AI_ACCESS_TOKEN); |
| | | if(StringUtils.hasLength(accessToken)){ |
| | | return accessToken; |
| | | } |
| | | TSysAiConfig sysAiConfig = sysAiConfigService.getById(1); |
| | | String result = HttpUtils.sendPost(H5_AI_URL, "devid="+sysAiConfig.getDevId()+"&devsecret="+sysAiConfig.getDevSecret()); |
| | | log.info("获取access_token:{}", result); |
| | | JSONObject object = JSONObject.parseObject(result); |
| | | if(object.getInteger("code") != 0){ |
| | | throw new ServiceException(object.getString("msg")); |
| | | } |
| | | JSONObject data = object.getJSONObject("data"); |
| | | accessToken = data.getString("access_token"); |
| | | Integer expiresIn = data.getInteger("expires_in"); |
| | | redisCache.setCacheObject(Constants.H5AI_ACCESS_TOKEN, accessToken, expiresIn-20, TimeUnit.SECONDS); |
| | | return accessToken; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.utils.util; |
| | | |
| | | import javax.crypto.Cipher; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.KeyFactory; |
| | | import java.security.PrivateKey; |
| | | import java.security.PublicKey; |
| | | import java.security.Signature; |
| | | import java.security.spec.PKCS8EncodedKeySpec; |
| | | import java.security.spec.X509EncodedKeySpec; |
| | | import java.util.Base64; |
| | | |
| | | /** |
| | | * rsa工具类 |
| | | * |
| | | * @author xuwenbing |
| | | * @date 2019-06-12 |
| | | */ |
| | | public class RsaSimpleUtil { |
| | | private static final String RSA = "RSA"; |
| | | private static final String MD5withRSA = "MD5withRSA"; |
| | | |
| | | /** |
| | | * 加密 |
| | | * |
| | | * @param source |
| | | * @param publicKeyBase64 |
| | | * @return |
| | | */ |
| | | public static String encrypt(String source, String publicKeyBase64) throws Exception { |
| | | // 获取publicKey |
| | | byte[] publicKeyBytes = Base64.getDecoder().decode(publicKeyBase64.getBytes(StandardCharsets.UTF_8)); |
| | | X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicKeyBytes); |
| | | KeyFactory keyFactory = KeyFactory.getInstance(RSA); |
| | | PublicKey publicKey = keyFactory.generatePublic(keySpec); |
| | | // 数据加密 |
| | | Cipher cipher = Cipher.getInstance(RSA); |
| | | cipher.init(Cipher.ENCRYPT_MODE, publicKey); |
| | | byte[] encryptBytes = cipher.doFinal(source.getBytes(StandardCharsets.UTF_8)); |
| | | return Base64.getEncoder().encodeToString(encryptBytes); |
| | | } |
| | | |
| | | /** |
| | | * 解密 |
| | | * |
| | | * @param encrypted |
| | | * @param privateKeyBase64 |
| | | * @return |
| | | */ |
| | | public static String decrypt(String encrypted, String privateKeyBase64) throws Exception { |
| | | // 获取privateKey |
| | | byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyBase64.getBytes(StandardCharsets.UTF_8)); |
| | | PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes); |
| | | KeyFactory keyFactory = KeyFactory.getInstance(RSA); |
| | | PrivateKey privateKey = keyFactory.generatePrivate(keySpec); |
| | | // 解密数据 |
| | | Cipher cipher = Cipher.getInstance(RSA); |
| | | cipher.init(Cipher.DECRYPT_MODE, privateKey); |
| | | byte[] decryptBytes = cipher.doFinal(Base64.getDecoder().decode(encrypted)); |
| | | return new String(decryptBytes, StandardCharsets.UTF_8); |
| | | } |
| | | |
| | | /** |
| | | * 签名 |
| | | * |
| | | * @param source |
| | | * @param privateKeyBase64 |
| | | * @return |
| | | */ |
| | | public static String sign(String source, String privateKeyBase64) throws Exception { |
| | | // 获取privateKey |
| | | byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyBase64.getBytes(StandardCharsets.UTF_8)); |
| | | PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes); |
| | | KeyFactory keyFactory = KeyFactory.getInstance(RSA); |
| | | PrivateKey privateKey = keyFactory.generatePrivate(keySpec); |
| | | // 签名 |
| | | Signature signature = Signature.getInstance(MD5withRSA); |
| | | signature.initSign(privateKey); |
| | | signature.update(source.getBytes(StandardCharsets.UTF_8)); |
| | | byte[] signed = signature.sign(); |
| | | return Base64.getEncoder().encodeToString(signed); |
| | | } |
| | | |
| | | /** |
| | | * 验签 |
| | | * |
| | | * @param source |
| | | * @param signed |
| | | * @param publicKeyBase64 |
| | | * @return |
| | | */ |
| | | public static boolean verify(String source, String signed, String publicKeyBase64) throws Exception { |
| | | // 获取publicKey |
| | | byte[] publicKeyBytes = Base64.getDecoder().decode(publicKeyBase64.getBytes(StandardCharsets.UTF_8)); |
| | | X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicKeyBytes); |
| | | KeyFactory keyFactory = KeyFactory.getInstance(RSA); |
| | | PublicKey publicKey = keyFactory.generatePublic(keySpec); |
| | | // 验签 |
| | | Signature signature = Signature.getInstance(MD5withRSA); |
| | | signature.initVerify(publicKey); |
| | | signature.update(source.getBytes(StandardCharsets.UTF_8)); |
| | | boolean verify = signature.verify(Base64.getDecoder().decode(signed)); |
| | | return verify; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.vo; |
| | | |
| | | import com.ruoyi.system.model.TSysInspection; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel(value = "用户检测信息管理VO") |
| | | public class TSysInspectionVO extends TSysInspection { |
| | | |
| | | @ApiModelProperty(value = "诊所名称") |
| | | private String clinicName; |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.system.mapper.TSysAiConfigMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TSysAiConfig"> |
| | | <id column="id" property="id" /> |
| | | <result column="devId" property="devId" /> |
| | | <result column="devSecret" property="devSecret" /> |
| | | <result column="devRsaPublicKey" property="devRsaPublicKey" /> |
| | | <result column="rsaPublicKey" property="rsaPublicKey" /> |
| | | <result column="aesKey" property="aesKey" /> |
| | | </resultMap> |
| | | |
| | | <!-- 通用查询结果列 --> |
| | | <sql id="Base_Column_List"> |
| | | id, devId, devSecret, devRsaPublicKey, rsaPublicKey,aesKey |
| | | </sql> |
| | | |
| | | </mapper> |
| | |
| | | <result column="symptom_name" property="symptomName" /> |
| | | <result column="tongue_feature" property="tongueFeature" /> |
| | | <result column="disease_risks" property="diseaseRisks" /> |
| | | <result column="is_pay" property="isPay" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="create_by" property="createBy" /> |
| | |
| | | |
| | | <!-- 通用查询结果列 --> |
| | | <sql id="Base_Column_List"> |
| | | id, app_user_id,clinic_id, inspection_info, team_code, team_name, device_code, device_name, person_name, person_sex, person_age, person_phone, person_height, person_weight, check_time, pdf_url, health_index, constitution_names, symptom_name, tongue_feature, disease_risks, create_time, update_time, create_by, update_by, disabled, create_id |
| | | id, app_user_id,clinic_id, inspection_info, team_code, team_name, device_code, device_name, person_name, |
| | | person_sex, person_age, person_phone, person_height, person_weight, check_time, pdf_url, health_index, |
| | | constitution_names, symptom_name, tongue_feature, disease_risks,is_pay, create_time, update_time, |
| | | create_by, update_by, disabled, create_id |
| | | </sql> |
| | | <select id="pageList" resultType="com.ruoyi.system.vo.TSysInspectionVO"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | FROM t_sys_inspection |
| | | <where> |
| | | <if test="query.appUserId != null and query.appUserId != ''"> |
| | | and app_user_id = #{query.appUserId} |
| | | </if> |
| | | AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | </where> |
| | | ORDER BY create_time DESC |
| | | </select> |
| | | |
| | | </mapper> |