Commit 12441ee8 authored by liqin's avatar liqin 💬

bug fixed

parent 3b349c57
package cn.wisenergy.chnmuseum.party.model;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Update;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -54,12 +55,19 @@ public class TBoxOperation implements Serializable {
@ApiModelProperty(hidden = true)
@TableField("public_key")
@JSONField(serialize = false)
private String publicKey;
@ApiModelProperty("机顶盒密钥")
@ApiModelProperty(hidden = true)
@TableField("private_key")
@JSONField(serialize = false)
private String privateKey;
@ApiModelProperty(hidden = true)
@TableField("request_count")
@JSONField(serialize = false)
private Integer requestCount;
@ApiModelProperty("创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime;
......
......@@ -117,20 +117,38 @@ public class ChinaMobileRestApiController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("equitment:key")
public Map<String, Object> getBoxPrivateKey(@RequestParam(value = "mac") String mac) {
try {
final LambdaQueryWrapper<TBoxOperation> queryWrapper = Wrappers.<TBoxOperation>lambdaQuery().eq(TBoxOperation::getMac, mac.trim().toUpperCase());
String macAddress = mac.trim().toUpperCase();
final LambdaQueryWrapper<TBoxOperation> queryWrapper = Wrappers.<TBoxOperation>lambdaQuery().eq(TBoxOperation::getMac, macAddress);
final TBoxOperation tBoxOperation = this.boxOperationService.getOne(queryWrapper);
if (tBoxOperation != null) {
final String organId = tBoxOperation.getOrganId();
final TUser tUser = getcurUser();
if (tUser != null && organId.equals(tUser.getOrgId())) {
final String countStr = this.stringRedisTemplate.opsForValue().get(macAddress + "_count");
if (StringUtils.isNotBlank(countStr)) {
final long count = Long.parseLong(countStr);
if (count > 1) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("key", "");
return getFailResult("400", "已经获取过一次,无法再次获取", jsonObject);
}
} else if (tBoxOperation.getRequestCount() > 1) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("key", "");
return getFailResult("400", "已经获取过一次,无法再次获取", jsonObject);
}
this.stringRedisTemplate.opsForValue().increment(macAddress + "_count");
tBoxOperation.setRequestCount(tBoxOperation.getRequestCount() + 1);
this.boxOperationService.updateById(tBoxOperation);
JSONObject jsonObject = new JSONObject();
jsonObject.put("key", tBoxOperation.getPrivateKey());
return getResult(jsonObject);
} else {
return getFailResult("400", "您无权获取本单位机顶盒密钥");
return getFailResult("400", "您无权获取机顶盒密钥");
}
}
return getFailResult("500", "未查询到相关机顶盒信息");
return getFailResult("400", "系统未查询到此机顶盒相关信息");
} catch (Exception e) {
e.printStackTrace();
}
......@@ -186,8 +204,8 @@ public class ChinaMobileRestApiController extends BaseController {
return resultMap;
}
//解密
mac=AESUtils.aesDecrypt(mac);
password= AESUtils.aesDecrypt(password);
mac = AESUtils.aesDecrypt(mac);
password = AESUtils.aesDecrypt(password);
if (!mac.equals(operation.getMac())) {
resultMap.put("resultCode", "400");
......@@ -354,11 +372,11 @@ public class ChinaMobileRestApiController extends BaseController {
resultMap.put("data", list);
return resultMap;
} catch (Exception e) {
resultMap.put("resultCode", "500");
resultMap.put("resultCode", "400");
resultMap.put("message", "该展板已下架");
resultMap.put("data", "");
}
return getFailResult("该展板已下架");
return getFailResult("400", "该展板已下架");
}
@ApiImplicitParams(value = {
......
......@@ -201,12 +201,17 @@ public class FileUploadController extends BaseController {
asset.setFileUrlCrypto(fileUrlCrypto);
asset.setFileCat(FileCatEnum.EXHIBITION_BOARD_DATUM.name());
asset.setLanguage(language);
if (Arrays.stream(VIDEO_TYPE).anyMatch(s -> Objects.equals(s, finalExtName.toUpperCase()))) {
asset.setCrc32((long) crc32);
}
asset.setCreateTime(createTime);
asset.setUpdateTime(createTime);
if (one != null) {
try {
FastDFSUtils.deleteFile(fileUrl);
FastDFSUtils.deleteFile(fileUrlCrypto);
} catch (Throwable ignored) {
}
asset.setFileUrl(one.getFileUrl());
asset.setFileUrlCrypto(one.getFileUrlCrypto());
}
......
......@@ -148,6 +148,19 @@ public class BaseController implements Serializable {
return map;
}
/**
* 返回失败
*
* @return map
*/
protected Map<String, Object> getFailResult(String code, String msg, Object obj) {
Map<String, Object> map = new LinkedHashMap<>();
map.put(RESULT_INFO_ENUM.RESULT_CODE.getKey(), code);
map.put(RESULT_INFO_ENUM.RESULT_MSG.getKey(), msg);
map.put(RESULT_INFO_ENUM.RESULT_BODY.getKey(), obj);
return map;
}
/**
* JSON 过滤相关字段
*
......
......@@ -9,8 +9,9 @@
<result column="mac" property="mac"/>
<result column="status" property="status"/>
<result column="area_id" property="areaId"/>
<result column="public_key" property="publicKey" />
<result column="private_key" property="privateKey" />
<result column="public_key" property="publicKey"/>
<result column="private_key" property="privateKey"/>
<result column="request_count" property="requestCount"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="organ_name" property="organName"/>
......@@ -22,7 +23,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, organ_id, mac, status, area_id, public_key, private_key, create_time, update_time
id, organ_id, mac, status, area_id, public_key, private_key, request_count, create_time, update_time
</sql>
<select id="getList" resultMap="BaseResultMap">
......@@ -40,7 +41,8 @@
</select>
<select id="selectBoxPage" resultMap="BaseResultMap">
select b.id,b.organ_id,b.mac,b.status,b.area_id,b.private_key,b.create_time,b.update_time,u.user_name organ_name,a.full_name area_name,u.permanent permanent,
select b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name organ_name,a.full_name
area_name,u.permanent permanent,
u.effective_date effective_date,u.exired_date exired_date
from t_box_operation b
left join t_organ o on b.organ_id = o.id
......@@ -63,7 +65,7 @@
</select>
<select id="selectPageList" resultMap="BaseResultMap">
SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.private_key,b.create_time,b.update_time,u.user_name organ_name
SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name organ_name
FROM t_box_operation b
left join t_organ r on r.id = b.organ_id
left join t_user u on u.org_id = b.organ_id and u.type = '3'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment