LIVE_YE 2 tuần trước cách đây
mục cha
commit
2e2826b814

+ 104 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/AppManageController.java

@@ -0,0 +1,104 @@
+package com.ruoyi.web.controller.app;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+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.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.manage.domain.AppManage;
+import com.ruoyi.manage.service.IAppManageService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * appkey管理Controller
+ *
+ * @author boman
+ * @date 2025-08-01
+ */
+@RestController
+@RequestMapping("/manage/manage")
+public class AppManageController extends BaseController
+{
+    @Autowired
+    private IAppManageService appManageService;
+
+/**
+ * 查询appkey管理列表
+ */
+@PreAuthorize("@ss.hasPermi('manage:manage:list')")
+@GetMapping("/list")
+    public TableDataInfo list(AppManage appManage)
+    {
+        startPage();
+        List<AppManage> list = appManageService.selectAppManageList(appManage);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出appkey管理列表
+     */
+    @PreAuthorize("@ss.hasPermi('manage:manage:export')")
+    @Log(title = "appkey管理", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, AppManage appManage)
+    {
+        List<AppManage> list = appManageService.selectAppManageList(appManage);
+        ExcelUtil<AppManage> util = new ExcelUtil<AppManage>(AppManage.class);
+        util.exportExcel(response, list, "appkey管理数据");
+    }
+
+    /**
+     * 获取appkey管理详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('manage:manage:query')")
+    @GetMapping(value = "/{appId}")
+    public AjaxResult getInfo(@PathVariable("appId") Long appId)
+    {
+        return success(appManageService.selectAppManageByAppId(appId));
+    }
+
+    /**
+     * 新增appkey管理
+     */
+    @PreAuthorize("@ss.hasPermi('manage:manage:add')")
+    @Log(title = "appkey管理", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody AppManage appManage)
+    {
+        return toAjax(appManageService.insertAppManage(appManage));
+    }
+
+    /**
+     * 修改appkey管理
+     */
+    @PreAuthorize("@ss.hasPermi('manage:manage:edit')")
+    @Log(title = "appkey管理", businessType = BusinessType.UPDATE)
+    @PostMapping("/put")
+    public AjaxResult edit(@RequestBody AppManage appManage)
+    {
+        return toAjax(appManageService.updateAppManage(appManage));
+    }
+
+    /**
+     * 删除appkey管理
+     */
+    @PreAuthorize("@ss.hasPermi('manage:manage:remove')")
+    @Log(title = "appkey管理", businessType = BusinessType.DELETE)
+    @GetMapping("/delete/{appIds}")
+    public AjaxResult remove(@PathVariable Long[] appIds)
+    {
+        return toAjax(appManageService.deleteAppManageByAppIds(appIds));
+    }
+}

+ 32 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/OcrController.java

@@ -8,6 +8,9 @@ import com.ruoyi.common.core.domain.IdCardVo;
 import com.ruoyi.common.core.domain.SysUserIdcardVo;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.IdCardUtil;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.manage.domain.AppManage;
+import com.ruoyi.manage.service.IAppManageService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -25,6 +28,9 @@ public class OcrController {
     @Autowired
     private RedisCache redisCache;
 
+    @Autowired
+    private IAppManageService appManageService;
+
     /**
      * 身份证识别
      *
@@ -33,6 +39,14 @@ public class OcrController {
     @PostMapping("/ocrIdCard")
     @RepeatSubmit(interval = 1000, message = "请求过于频繁")
     public AjaxResult ocrIdCard(@RequestBody IdCardVo idCardVo) {
+        if(StringUtils.isEmpty(idCardVo.getAppkey())){
+            return AjaxResult.error("appKey不能为空");
+        }
+        //查询appKey是否存在
+        AppManage appManage = appManageService.selectAppManageByAppKey(idCardVo.getAppkey());
+        if(appManage==null){
+            return AjaxResult.error("非法访问");
+        }
         return IdCardUtil.idCard(idCardVo.getImage(), idCardVo.getIdCardSide());
     }
 
@@ -48,6 +62,16 @@ public class OcrController {
     @PostMapping("/ocrSampleAliYun")
     @RepeatSubmit(interval = 1000, message = "请求过于频繁")
     public AjaxResult ocrSampleAliYun(@RequestBody SysUserIdcardVo sysUserIdcardVo) {
+
+        if(StringUtils.isEmpty(sysUserIdcardVo.getAppkey())){
+            return AjaxResult.error("appKey不能为空");
+        }
+        //查询appKey是否存在
+        AppManage appManage = appManageService.selectAppManageByAppKey(sysUserIdcardVo.getAppkey());
+        if(appManage==null){
+            return AjaxResult.error("非法访问");
+        }
+
         return IdCardUtil.ocrSampleAliYun(sysUserIdcardVo);
     }
 
@@ -59,6 +83,14 @@ public class OcrController {
     @PostMapping("/ocrSampleAliYunH")
     @RepeatSubmit(interval = 1000, message = "请求过于频繁")
     public AjaxResult ocrSampleAliYunH(@RequestBody SysUserIdcardVo sysUserIdcardVo) {
+        if(StringUtils.isEmpty(sysUserIdcardVo.getAppkey())){
+            return AjaxResult.error("appKey不能为空");
+        }
+        //查询appKey是否存在
+        AppManage appManage = appManageService.selectAppManageByAppKey(sysUserIdcardVo.getAppkey());
+        if(appManage==null){
+            return AjaxResult.error("非法访问");
+        }
         InitFaceVerifyResponseBody.InitFaceVerifyResponseBodyResultObject result = IdCardUtil.initFaceVerifyH5(sysUserIdcardVo);
 /*        String certifyId = result.getCertifyId();
         redisCache.setCacheObject(certifyId, sysUserIdcardVo);*/

+ 10 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/IdCardVo.java

@@ -27,6 +27,8 @@ public class IdCardVo implements Serializable {
      */
     private String idCardSide;
 
+    private String appkey;
+
     public String getIdCardSide() {
         return idCardSide;
     }
@@ -59,6 +61,14 @@ public class IdCardVo implements Serializable {
         this.image = image;
     }
 
+    public String getAppkey() {
+        return appkey;
+    }
+
+    public void setAppkey(String appkey) {
+        this.appkey = appkey;
+    }
+
     @Override
     public String toString() {
         return "IdCardVo{" +

+ 10 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/SysUserIdcardVo.java

@@ -67,6 +67,8 @@ public class SysUserIdcardVo extends BaseEntity
      */
     private String returnUrl;
 
+    private String appkey;
+
     public String getReturnUrl() {
         return returnUrl;
     }
@@ -181,6 +183,14 @@ public class SysUserIdcardVo extends BaseEntity
         return delFlag;
     }
 
+    public String getAppkey() {
+        return appkey;
+    }
+
+    public void setAppkey(String appkey) {
+        this.appkey = appkey;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 86 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/domain/AppManage.java

@@ -0,0 +1,86 @@
+package com.ruoyi.manage.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * appkey管理对象 app_manage
+ * 
+ * @author boman
+ * @date 2025-08-01
+ */
+public class AppManage extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** appID */
+    private Long appId;
+
+    /** 秘钥 */
+    @Excel(name = "秘钥")
+    private String appKey;
+
+    /** app名称 */
+    @Excel(name = "app名称")
+    private String appName;
+
+    /** 删除标志(0代表存在 1代表删除) */
+    private String delFlag;
+
+    public void setAppId(Long appId) 
+    {
+        this.appId = appId;
+    }
+
+    public Long getAppId() 
+    {
+        return appId;
+    }
+
+    public void setAppKey(String appKey) 
+    {
+        this.appKey = appKey;
+    }
+
+    public String getAppKey() 
+    {
+        return appKey;
+    }
+
+    public void setAppName(String appName) 
+    {
+        this.appName = appName;
+    }
+
+    public String getAppName() 
+    {
+        return appName;
+    }
+
+    public void setDelFlag(String delFlag) 
+    {
+        this.delFlag = delFlag;
+    }
+
+    public String getDelFlag() 
+    {
+        return delFlag;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("appId", getAppId())
+            .append("appKey", getAppKey())
+            .append("appName", getAppName())
+            .append("delFlag", getDelFlag())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .toString();
+    }
+}

+ 69 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/mapper/AppManageMapper.java

@@ -0,0 +1,69 @@
+package com.ruoyi.manage.mapper;
+
+import java.util.List;
+import com.ruoyi.manage.domain.AppManage;
+
+/**
+ * appkey管理Mapper接口
+ * 
+ * @author boman
+ * @date 2025-08-01
+ */
+public interface AppManageMapper 
+{
+    /**
+     * 查询appkey管理
+     * 
+     * @param appId appkey管理主键
+     * @return appkey管理
+     */
+    public AppManage selectAppManageByAppId(Long appId);
+
+    /**
+     * 查询appkey管理
+     *
+     * @param appKey appkey管理主键
+     * @return appkey管理
+     */
+    public AppManage selectAppManageByAppKey(String appKey);
+
+    /**
+     * 查询appkey管理列表
+     * 
+     * @param appManage appkey管理
+     * @return appkey管理集合
+     */
+    public List<AppManage> selectAppManageList(AppManage appManage);
+
+    /**
+     * 新增appkey管理
+     * 
+     * @param appManage appkey管理
+     * @return 结果
+     */
+    public int insertAppManage(AppManage appManage);
+
+    /**
+     * 修改appkey管理
+     * 
+     * @param appManage appkey管理
+     * @return 结果
+     */
+    public int updateAppManage(AppManage appManage);
+
+    /**
+     * 删除appkey管理
+     * 
+     * @param appId appkey管理主键
+     * @return 结果
+     */
+    public int deleteAppManageByAppId(Long appId);
+
+    /**
+     * 批量删除appkey管理
+     * 
+     * @param appIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteAppManageByAppIds(Long[] appIds);
+}

+ 63 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/service/IAppManageService.java

@@ -0,0 +1,63 @@
+package com.ruoyi.manage.service;
+
+import java.util.List;
+import com.ruoyi.manage.domain.AppManage;
+
+/**
+ * appkey管理Service接口
+ * 
+ * @author boman
+ * @date 2025-08-01
+ */
+public interface IAppManageService 
+{
+    /**
+     * 查询appkey管理
+     * 
+     * @param appId appkey管理主键
+     * @return appkey管理
+     */
+    public AppManage selectAppManageByAppId(Long appId);
+
+    /**
+     * 查询appkey管理列表
+     * 
+     * @param appManage appkey管理
+     * @return appkey管理集合
+     */
+    public List<AppManage> selectAppManageList(AppManage appManage);
+
+    /**
+     * 新增appkey管理
+     * 
+     * @param appManage appkey管理
+     * @return 结果
+     */
+    public int insertAppManage(AppManage appManage);
+
+    /**
+     * 修改appkey管理
+     * 
+     * @param appManage appkey管理
+     * @return 结果
+     */
+    public int updateAppManage(AppManage appManage);
+
+    /**
+     * 批量删除appkey管理
+     * 
+     * @param appIds 需要删除的appkey管理主键集合
+     * @return 结果
+     */
+    public int deleteAppManageByAppIds(Long[] appIds);
+
+    /**
+     * 删除appkey管理信息
+     * 
+     * @param appId appkey管理主键
+     * @return 结果
+     */
+    public int deleteAppManageByAppId(Long appId);
+
+    AppManage selectAppManageByAppKey(String appkey);
+}

+ 105 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/AppManageServiceImpl.java

@@ -0,0 +1,105 @@
+package com.ruoyi.manage.service.impl;
+
+import java.util.List;
+import java.util.UUID;
+
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.uuid.IdUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.manage.mapper.AppManageMapper;
+import com.ruoyi.manage.domain.AppManage;
+import com.ruoyi.manage.service.IAppManageService;
+
+/**
+ * appkey管理Service业务层处理
+ * 
+ * @author boman
+ * @date 2025-08-01
+ */
+@Service
+public class AppManageServiceImpl implements IAppManageService 
+{
+    @Autowired
+    private AppManageMapper appManageMapper;
+
+    /**
+     * 查询appkey管理
+     * 
+     * @param appId appkey管理主键
+     * @return appkey管理
+     */
+    @Override
+    public AppManage selectAppManageByAppId(Long appId)
+    {
+        return appManageMapper.selectAppManageByAppId(appId);
+    }
+
+    /**
+     * 查询appkey管理列表
+     * 
+     * @param appManage appkey管理
+     * @return appkey管理
+     */
+    @Override
+    public List<AppManage> selectAppManageList(AppManage appManage)
+    {
+        return appManageMapper.selectAppManageList(appManage);
+    }
+
+    /**
+     * 新增appkey管理
+     * 
+     * @param appManage appkey管理
+     * @return 结果
+     */
+    @Override
+    public int insertAppManage(AppManage appManage)
+    {
+        appManage.setAppKey(IdUtils.simpleUUID());
+        appManage.setCreateTime(DateUtils.getNowDate());
+        return appManageMapper.insertAppManage(appManage);
+    }
+
+    /**
+     * 修改appkey管理
+     * 
+     * @param appManage appkey管理
+     * @return 结果
+     */
+    @Override
+    public int updateAppManage(AppManage appManage)
+    {
+        appManage.setUpdateTime(DateUtils.getNowDate());
+        return appManageMapper.updateAppManage(appManage);
+    }
+
+    /**
+     * 批量删除appkey管理
+     * 
+     * @param appIds 需要删除的appkey管理主键
+     * @return 结果
+     */
+    @Override
+    public int deleteAppManageByAppIds(Long[] appIds)
+    {
+        return appManageMapper.deleteAppManageByAppIds(appIds);
+    }
+
+    /**
+     * 删除appkey管理信息
+     * 
+     * @param appId appkey管理主键
+     * @return 结果
+     */
+    @Override
+    public int deleteAppManageByAppId(Long appId)
+    {
+        return appManageMapper.deleteAppManageByAppId(appId);
+    }
+
+    @Override
+    public AppManage selectAppManageByAppKey(String appkey) {
+        return appManageMapper.selectAppManageByAppKey(appkey);
+    }
+}

+ 89 - 0
ruoyi-system/src/main/resources/mapper/manage/AppManageMapper.xml

@@ -0,0 +1,89 @@
+<?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.manage.mapper.AppManageMapper">
+    
+    <resultMap type="AppManage" id="AppManageResult">
+        <result property="appId"    column="app_id"    />
+        <result property="appKey"    column="app_key"    />
+        <result property="appName"    column="app_name"    />
+        <result property="delFlag"    column="del_flag"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectAppManageVo">
+        select app_id, app_key, app_name, del_flag, create_by, create_time, update_by, update_time, remark from app_manage
+    </sql>
+
+    <select id="selectAppManageList" parameterType="AppManage" resultMap="AppManageResult">
+        <include refid="selectAppManageVo"/>
+        <where>  
+            <if test="appKey != null  and appKey != ''"> and app_key = #{appKey}</if>
+            <if test="appName != null  and appName != ''"> and app_name like concat('%', #{appName}, '%')</if>
+        </where>
+    </select>
+    
+    <select id="selectAppManageByAppId" parameterType="Long" resultMap="AppManageResult">
+        <include refid="selectAppManageVo"/>
+        where app_id = #{appId}
+    </select>
+    <select id="selectAppManageByAppKey" parameterType="String" resultMap="AppManageResult">
+        <include refid="selectAppManageVo"/>
+        where app_key = #{appKey}
+    </select>
+
+    <insert id="insertAppManage" parameterType="AppManage" useGeneratedKeys="true" keyProperty="appId">
+        insert into app_manage
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="appKey != null and appKey != ''">app_key,</if>
+            <if test="appName != null and appName != ''">app_name,</if>
+            <if test="delFlag != null">del_flag,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="appKey != null and appKey != ''">#{appKey},</if>
+            <if test="appName != null and appName != ''">#{appName},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateAppManage" parameterType="AppManage">
+        update app_manage
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="appKey != null and appKey != ''">app_key = #{appKey},</if>
+            <if test="appName != null and appName != ''">app_name = #{appName},</if>
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where app_id = #{appId}
+    </update>
+
+    <delete id="deleteAppManageByAppId" parameterType="Long">
+        delete from app_manage where app_id = #{appId}
+    </delete>
+
+    <delete id="deleteAppManageByAppIds" parameterType="String">
+        delete from app_manage where app_id in 
+        <foreach item="appId" collection="array" open="(" separator="," close=")">
+            #{appId}
+        </foreach>
+    </delete>
+</mapper>