| | |
| | | |
| | | LOGIN_TIMEOUT(2016, "登录超时,请重新登录"), |
| | | |
| | | OPERATOR_TYPE_FETCH_FAIL(3001, "获取操作员失败"); |
| | | |
| | | OPERATOR_TYPE_FETCH_FAIL(3001, "获取操作员失败"), |
| | | APPID_ERROR(3002, "appId错误"), |
| | | APPKEY_ERROR(3003, "appKey错误"), |
| | | SIGN_ERROR(3004,"sign错误"); |
| | | |
| | | private long code; |
| | | private String message; |
New file |
| | |
| | | package com.ycl.utils; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * @author Lyq |
| | | * @version 1.0 |
| | | * @date 2022/10/31 |
| | | */ |
| | | public class MD5Util { |
| | | /** |
| | | * MD5加密字符串(32位大写) |
| | | * |
| | | * @param string 需要进行MD5加密的字符串 |
| | | * @return 加密后的字符串(大写) |
| | | */ |
| | | public static String md5Encrypt32Upper(String string) { |
| | | byte[] hash; |
| | | try { |
| | | //创建一个MD5算法对象,并获得MD5字节数组,16*8=128位 |
| | | hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8")); |
| | | } catch (NoSuchAlgorithmException e) { |
| | | throw new RuntimeException("Huh, MD5 should be supported?", e); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException("Huh, UTF-8 should be supported?", e); |
| | | } |
| | | |
| | | //转换为十六进制字符串 |
| | | StringBuilder hex = new StringBuilder(hash.length * 2); |
| | | for (byte b : hash) { |
| | | if ((b & 0xFF) < 0x10) hex.append("0"); |
| | | hex.append(Integer.toHexString(b & 0xFF)); |
| | | } |
| | | return hex.toString().toUpperCase(); |
| | | } |
| | | |
| | | /** |
| | | * MD5加密字符串(32位小写) |
| | | * |
| | | * @param string 需要进行MD5加密的字符串 |
| | | * @return 加密后的字符串(小写) |
| | | */ |
| | | public static String md5Encrypt32Lower(String string) { |
| | | byte[] hash; |
| | | try { |
| | | //创建一个MD5算法对象,并获得MD5字节数组,16*8=128位 |
| | | hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8")); |
| | | } catch (NoSuchAlgorithmException e) { |
| | | throw new RuntimeException("Huh, MD5 should be supported?", e); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException("Huh, UTF-8 should be supported?", e); |
| | | } |
| | | |
| | | //转换为十六进制字符串 |
| | | StringBuilder hex = new StringBuilder(hash.length * 2); |
| | | for (byte b : hash) { |
| | | if ((b & 0xFF) < 0x10) hex.append("0"); |
| | | hex.append(Integer.toHexString(b & 0xFF)); |
| | | } |
| | | return hex.toString().toLowerCase(); |
| | | } |
| | | |
| | | /** |
| | | * 将二进制字节数组转换为十六进制字符串 |
| | | * |
| | | * @param bytes 二进制字节数组 |
| | | * @return 十六进制字符串 |
| | | */ |
| | | public static String bytesToHex(byte[] bytes) { |
| | | StringBuffer hexStr = new StringBuffer(); |
| | | int num; |
| | | for (int i = 0; i < bytes.length; i++) { |
| | | num = bytes[i]; |
| | | if (num < 0) { |
| | | num += 256; |
| | | } |
| | | if (num < 16) { |
| | | hexStr.append("0"); |
| | | } |
| | | hexStr.append(Integer.toHexString(num)); |
| | | } |
| | | return hexStr.toString().toUpperCase(); |
| | | } |
| | | |
| | | /** |
| | | * Unicode中文编码转换成字符串 |
| | | */ |
| | | public static String unicodeToString(String str) { |
| | | Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))"); |
| | | Matcher matcher = pattern.matcher(str); |
| | | char ch; |
| | | while (matcher.find()) { |
| | | ch = (char) Integer.parseInt(matcher.group(2), 16); |
| | | str = str.replace(matcher.group(1), ch + ""); |
| | | } |
| | | return str; |
| | | } |
| | | } |
| | |
| | | @ApiModelProperty(value = "appKey", example = "1") |
| | | @NotBlank(message = "appKey不能为空") |
| | | private String appKey; |
| | | @ApiModelProperty(value = "sign", example = "sfagjgfjgfjdgfjsgdfgsa") |
| | | @NotBlank(message = "sign不能为空") |
| | | private String sign; |
| | | } |
| | | |
| | |
| | | @ApiModelProperty(value = "appKey", example = "1") |
| | | @NotBlank(message = "appKey不能为空") |
| | | private String appKey; |
| | | @ApiModelProperty(value = "sign", example = "sfagjgfjgfjdgfjsgdfgsa") |
| | | @NotBlank(message = "sign不能为空") |
| | | private String sign; |
| | | @ApiModelProperty(value = "开始时间,格式yyyy-MM-dd hh:mm:ss") |
| | | @ApiModelProperty(value = "开始时间,格式yyyy-MM-dd hh:mm:ss",example = "2022-10-22 13:22:22") |
| | | @NotBlank(message = "开始时间不能为空") |
| | | private String beginTime; |
| | | @ApiModelProperty(value = "结束时间,格式yyyy-MM-dd hh:mm:ss") |
| | | @ApiModelProperty(value = "结束时间,格式yyyy-MM-dd hh:mm:ss",example = "2022-10-23 13:22:22") |
| | | @NotBlank(message = "结束时间不能为空") |
| | | private String endTime; |
| | | } |
| | | } |
| | |
| | | GlobalConfig gc = new GlobalConfig(); |
| | | final String projectPath = System.getProperty("user.dir"); |
| | | gc.setOutputDir(projectPath + "/ycl-generator/src/main/java"); |
| | | gc.setAuthor("zhanghua");//作者 |
| | | gc.setAuthor("lyq");//作者 |
| | | gc.setBaseResultMap(true); //mapper.xml 生成 ResultMap |
| | | gc.setBaseColumnList(true); //mapper.xml 生成 ColumnList |
| | | // gc.setSwagger2(true); |
| | |
| | | package com.ycl.controller.cockpit.aiIot; |
| | | |
| | | import com.ycl.api.CommonResult; |
| | | import com.ycl.util.CheckApiUtil; |
| | | import com.ycl.vo.cockpit.CockpitVO; |
| | | import com.ycl.vo.cockpit.aiIot.AIIotVO; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | |
| | | @RequestMapping("/api/lot") |
| | | public class AIIotController { |
| | | |
| | | @Resource |
| | | private CheckApiUtil checkApiUtil; |
| | | |
| | | @ApiOperation(value = "监测数据") |
| | | @GetMapping("/detection") |
| | | public CommonResult<AIIotVO.DetectionVO> detection(@Validated CockpitVO.Params1VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), null, null); |
| | | AIIotVO.DetectionVO detectionVO = new AIIotVO.DetectionVO(); |
| | | detectionVO.setVideo(121); |
| | | detectionVO.setIndividual(20); |
| | |
| | | @ApiOperation(value = "实时视频监控") |
| | | @GetMapping("/video") |
| | | public CommonResult<List<AIIotVO.VideoVO>> video(@Validated CockpitVO.Params1VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), null, null); |
| | | List<AIIotVO.VideoVO> videoVOS = new ArrayList<>(); |
| | | AIIotVO.VideoVO a = null; |
| | | for (int i = 0; i < 4; i++) { |
| | |
| | | @ApiOperation(value = "AI算法效能") |
| | | @GetMapping("/efficiency") |
| | | public CommonResult<List<AIIotVO.EfficiencyVO>> efficiency(@Validated CockpitVO.Params2VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), params.getBeginTime(), params.getEndTime()); |
| | | List<AIIotVO.EfficiencyVO> efficiencyVOS = new ArrayList<>(); |
| | | AIIotVO.EfficiencyVO a = null; |
| | | for (int i = 0; i < 4; i++) { |
| | |
| | | @ApiOperation(value = "渣土联动") |
| | | @GetMapping("/slag_car") |
| | | public CommonResult<AIIotVO.SlagCarVO> slagCar(@Validated CockpitVO.Params1VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), null, null); |
| | | AIIotVO.SlagCarVO slagCarVO = new AIIotVO.SlagCarVO(); |
| | | slagCarVO.setCar(236); |
| | | slagCarVO.setTeam(20); |
| | |
| | | @ApiOperation(value = "AI事件统计") |
| | | @GetMapping("/event_statistics") |
| | | public CommonResult<List<AIIotVO.StatisticsVO>> statistics(@Validated CockpitVO.Params2VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), params.getBeginTime(), params.getEndTime()); |
| | | List<AIIotVO.StatisticsVO> statisticsVOS = new ArrayList<>(); |
| | | List<AIIotVO.Statistics1VO> statistics1VOS = new ArrayList<>(); |
| | | AIIotVO.StatisticsVO a = null; |
| | |
| | | package com.ycl.controller.cockpit.enforcementEvents; |
| | | |
| | | import com.ycl.api.CommonResult; |
| | | import com.ycl.util.CheckApiUtil; |
| | | import com.ycl.vo.cockpit.CockpitVO; |
| | | import com.ycl.vo.cockpit.enforcementEvents.EnforcementEventsVO; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | |
| | | @RestController |
| | | @RequestMapping("/api/event") |
| | | public class EnforcementEventsController { |
| | | @Resource |
| | | private CheckApiUtil checkApiUtil; |
| | | |
| | | @ApiOperation(value = "执法事件统计") |
| | | @GetMapping("/statistics") |
| | | public CommonResult<Map<String, Object>> statistics(@Validated CockpitVO.Params2VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), params.getBeginTime(), params.getEndTime()); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | EnforcementEventsVO.StatisticsEventVO eventVO = new EnforcementEventsVO.StatisticsEventVO(); |
| | | eventVO.setCount(10); |
| | | eventVO.setRatio(new BigDecimal("0.69").setScale(2, RoundingMode.HALF_UP)); |
| | | map.put("reported", eventVO); |
| | | map.put("disposition", eventVO); |
| | | map.put("dispositionInTime",eventVO); |
| | | map.put("dispositionInTime", eventVO); |
| | | map.put("register", eventVO); |
| | | return CommonResult.success(map); |
| | | } |
| | |
| | | @ApiOperation(value = "事件类型") |
| | | @GetMapping("/type") |
| | | public CommonResult<EnforcementEventsVO.TypeAndSourceVO> type(@Validated CockpitVO.Params2VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), params.getBeginTime(), params.getEndTime()); |
| | | List<EnforcementEventsVO.TypeAndSourceVO1> typeVO1s = new ArrayList<>(); |
| | | EnforcementEventsVO.TypeAndSourceVO typeVO = new EnforcementEventsVO.TypeAndSourceVO(); |
| | | EnforcementEventsVO.TypeAndSourceVO1 typeVO1 = null; |
| | |
| | | @ApiOperation(value = "视频抓拍告发点位") |
| | | @GetMapping("/video") |
| | | public CommonResult<List<EnforcementEventsVO.VideoAndAreaVO>> video(@Validated CockpitVO.Params2VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), params.getBeginTime(), params.getEndTime()); |
| | | List<EnforcementEventsVO.VideoAndAreaVO> videoVOS = new ArrayList<>(); |
| | | EnforcementEventsVO.VideoAndAreaVO videoVO = null; |
| | | for (int i = 0; i < 4; i++) { |
| | |
| | | @ApiOperation(value = "事件来源") |
| | | @GetMapping("/source") |
| | | public CommonResult<EnforcementEventsVO.TypeAndSourceVO> source(@Validated CockpitVO.Params2VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), params.getBeginTime(), params.getEndTime()); |
| | | List<EnforcementEventsVO.TypeAndSourceVO1> typeVO1s = new ArrayList<>(); |
| | | EnforcementEventsVO.TypeAndSourceVO typeVO = new EnforcementEventsVO.TypeAndSourceVO(); |
| | | EnforcementEventsVO.TypeAndSourceVO1 typeVO1 = null; |
| | |
| | | @ApiOperation(value = "事件区域统计") |
| | | @GetMapping("/area") |
| | | public CommonResult<List<EnforcementEventsVO.VideoAndAreaVO>> area(@Validated CockpitVO.Params2VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), params.getBeginTime(), params.getEndTime()); |
| | | List<EnforcementEventsVO.VideoAndAreaVO> videoVOS = new ArrayList<>(); |
| | | EnforcementEventsVO.VideoAndAreaVO videoVO = null; |
| | | for (int i = 0; i < 4; i++) { |
| | |
| | | @ApiOperation(value = "延误事件") |
| | | @GetMapping("/delay") |
| | | public CommonResult<List<EnforcementEventsVO.DelayVO>> delay(@Validated CockpitVO.Params2VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), params.getBeginTime(), params.getEndTime()); |
| | | List<EnforcementEventsVO.DelayVO> delayVOS = new ArrayList<>(); |
| | | EnforcementEventsVO.DelayVO delayVO = null; |
| | | for (int i = 0; i < 4; i++) { |
| | |
| | | @ApiOperation(value = "事件信息") |
| | | @GetMapping("/info") |
| | | public CommonResult<EnforcementEventsVO.InfoVO> info(@Validated CockpitVO.Params2VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), params.getBeginTime(), params.getEndTime()); |
| | | EnforcementEventsVO.InfoVO infoVO = new EnforcementEventsVO.InfoVO(); |
| | | EnforcementEventsVO.EventVO eventVO = new EnforcementEventsVO.EventVO(); |
| | | infoVO.setToday(5); |
| | |
| | | package com.ycl.controller.cockpit.statisticsEvents; |
| | | |
| | | import com.ycl.api.CommonResult; |
| | | import com.ycl.util.CheckApiUtil; |
| | | import com.ycl.vo.cockpit.CockpitVO; |
| | | import com.ycl.vo.cockpit.statisticsEvents.StatisticsEventsVO; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | |
| | | @RestController |
| | | @RequestMapping("/api/data") |
| | | public class StatisticsEventsController { |
| | | @Resource |
| | | private CheckApiUtil checkApiUtil; |
| | | |
| | | @ApiOperation(value = "执法事件") |
| | | @GetMapping("/law_enforcement_event") |
| | | public CommonResult<List<StatisticsEventsVO.LawEnforcementEventVO>> detection(@Validated CockpitVO.Params2VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), params.getBeginTime(), params.getEndTime()); |
| | | List<StatisticsEventsVO.LawEnforcementEventVO> lawEnforcementEventVOS = new ArrayList<>(); |
| | | StatisticsEventsVO.LawEnforcementEventVO a = null; |
| | | for (int i = 0; i < 4; i++) { |
| | |
| | | @ApiOperation(value = "物联感知") |
| | | @GetMapping("/lot") |
| | | public CommonResult<List<StatisticsEventsVO.LotVO>> lot(@Validated CockpitVO.Params1VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), null, null); |
| | | List<StatisticsEventsVO.LotVO> lotVOS = new ArrayList<>(); |
| | | StatisticsEventsVO.LotVO a = null; |
| | | for (int i = 0; i < 4; i++) { |
| | |
| | | @ApiOperation(value = "执法队伍") |
| | | @GetMapping("/team") |
| | | public CommonResult<StatisticsEventsVO.TeamVO> team(@Validated CockpitVO.Params1VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), null, null); |
| | | StatisticsEventsVO.TeamVO teamVO = new StatisticsEventsVO.TeamVO(); |
| | | teamVO.setAll(30); |
| | | teamVO.setAssistant(10); |
| | |
| | | @ApiOperation(value = "网格员") |
| | | @GetMapping("/grid_member") |
| | | public CommonResult<List<StatisticsEventsVO.GridMemberVO>> gridMember(@Validated CockpitVO.Params1VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), null, null); |
| | | List<StatisticsEventsVO.GridMemberVO> gridMemberVOS = new ArrayList<>(); |
| | | StatisticsEventsVO.GridMemberVO a = null; |
| | | for (int i = 0; i < 4; i++) { |
| | |
| | | @ApiOperation(value = "指数体征") |
| | | @GetMapping("/index_signs") |
| | | public CommonResult<StatisticsEventsVO.IndexSignsVO> indexSigns(@Validated CockpitVO.Params1VO params) { |
| | | checkApiUtil.cockpit(params.getAppId(), params.getAppKey(), params.getSign(), null, null); |
| | | StatisticsEventsVO.IndexSignsVO indexSignsVO = new StatisticsEventsVO.IndexSignsVO(); |
| | | indexSignsVO.setEvent(1); |
| | | indexSignsVO.setGridMember(20); |
New file |
| | |
| | | package com.ycl.entity.apiKey; |
| | | |
| | | 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 lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author lyq |
| | | * @since 2022-10-31 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @TableName("ums_api_key") |
| | | public class ApiKey implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | @TableField("name") |
| | | private String name; |
| | | |
| | | @TableField("app_id") |
| | | private String appId; |
| | | |
| | | @TableField("app_key") |
| | | private String appKey; |
| | | |
| | | @TableField("create_time") |
| | | private LocalDateTime createTime; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.mapper.apiKey; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ycl.entity.apiKey.ApiKey; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author lyq |
| | | * @since 2022-10-31 |
| | | */ |
| | | public interface ApiKeyMapper extends BaseMapper<ApiKey> { |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.service.apiKey; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ycl.entity.apiKey.ApiKey; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author lyq |
| | | * @since 2022-10-31 |
| | | */ |
| | | public interface IApiKeyService extends IService<ApiKey> { |
| | | |
| | | /** |
| | | * 校验apikey,appId |
| | | * |
| | | * @param appId |
| | | * @param appKey |
| | | * @param name |
| | | */ |
| | | void checkIsExist(String appId, String appKey, String name); |
| | | } |
New file |
| | |
| | | package com.ycl.service.apiKey.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.entity.apiKey.ApiKey; |
| | | import com.ycl.enums.common.ResultCode; |
| | | import com.ycl.exception.ApiException; |
| | | import com.ycl.mapper.apiKey.ApiKeyMapper; |
| | | import com.ycl.service.apiKey.IApiKeyService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author lyq |
| | | * @since 2022-10-31 |
| | | */ |
| | | @Service |
| | | public class ApiKeyServiceImpl extends ServiceImpl<ApiKeyMapper, ApiKey> implements IApiKeyService { |
| | | @Resource |
| | | private ApiKeyMapper apiKeyMapper; |
| | | |
| | | @Override |
| | | public void checkIsExist(String appId, String appKey, String name) { |
| | | ApiKey apiKey = this.queryByName(name); |
| | | if (!appId.equals(apiKey.getAppId())) { |
| | | throw new ApiException(ResultCode.APPID_ERROR); |
| | | } |
| | | if (!appKey.equals(apiKey.getAppKey())) { |
| | | throw new ApiException(ResultCode.APPKEY_ERROR); |
| | | } |
| | | } |
| | | |
| | | public ApiKey queryByName(String name) { |
| | | ApiKey apiKey = apiKeyMapper.selectOne(new LambdaQueryWrapper<ApiKey>().eq(ApiKey::getName, name)); |
| | | return apiKey; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ycl.util; |
| | | |
| | | import com.ycl.enums.common.ResultCode; |
| | | import com.ycl.exception.ApiException; |
| | | import com.ycl.service.apiKey.IApiKeyService; |
| | | import com.ycl.utils.MD5Util; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @author Lyq |
| | | * @version 1.0 |
| | | * @date 2022/10/31 |
| | | */ |
| | | @Component |
| | | public class CheckApiUtil { |
| | | |
| | | @Resource |
| | | private IApiKeyService apiKeyService; |
| | | |
| | | /** |
| | | * 驾驶舱 |
| | | * |
| | | * @param appId |
| | | * @param appKey |
| | | * @param sign |
| | | * @param name |
| | | * @param beginTime |
| | | * @param endTime |
| | | */ |
| | | public void cockpit(String appId, String appKey, String sign, String beginTime, String endTime) { |
| | | apiKeyService.checkIsExist(appId, appKey, "驾驶仓"); |
| | | StringBuffer sb = new StringBuffer(); |
| | | sb.append(appId); |
| | | sb.append(appKey); |
| | | String result; |
| | | if (!StringUtils.isBlank(beginTime) && !StringUtils.isBlank(endTime)) { |
| | | sb.append(beginTime); |
| | | sb.append(endTime); |
| | | } |
| | | result = MD5Util.md5Encrypt32Lower(sb.toString()); |
| | | if (!sign.equals(result)) { |
| | | throw new ApiException(ResultCode.SIGN_ERROR); |
| | | } |
| | | } |
| | | } |
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.ycl.mapper.apiKey.ApiKeyMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.ycl.entity.apiKey.ApiKey"> |
| | | <id column="id" property="id" /> |
| | | <result column="name" property="name" /> |
| | | <result column="app_id" property="appId" /> |
| | | <result column="app_key" property="appKey" /> |
| | | <result column="create_time" property="createTime" /> |
| | | </resultMap> |
| | | |
| | | <!-- 通用查询结果列 --> |
| | | <sql id="Base_Column_List"> |
| | | id, name, app_id, app_key, create_time |
| | | </sql> |
| | | |
| | | </mapper> |