Commit 12441ee8 authored by liqin's avatar liqin 💬

bug fixed

parent 3b349c57
package cn.wisenergy.chnmuseum.party.model; package cn.wisenergy.chnmuseum.party.model;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Update; import cn.wisenergy.chnmuseum.party.common.validator.groups.Update;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -54,12 +55,19 @@ public class TBoxOperation implements Serializable { ...@@ -54,12 +55,19 @@ public class TBoxOperation implements Serializable {
@ApiModelProperty(hidden = true) @ApiModelProperty(hidden = true)
@TableField("public_key") @TableField("public_key")
@JSONField(serialize = false)
private String publicKey; private String publicKey;
@ApiModelProperty("机顶盒密钥") @ApiModelProperty(hidden = true)
@TableField("private_key") @TableField("private_key")
@JSONField(serialize = false)
private String privateKey; private String privateKey;
@ApiModelProperty(hidden = true)
@TableField("request_count")
@JSONField(serialize = false)
private Integer requestCount;
@ApiModelProperty("创建时间") @ApiModelProperty("创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT) @TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime; private LocalDateTime createTime;
......
...@@ -117,20 +117,38 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -117,20 +117,38 @@ public class ChinaMobileRestApiController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("equitment:key") @RequiresAuthentication //@RequiresPermissions("equitment:key")
public Map<String, Object> getBoxPrivateKey(@RequestParam(value = "mac") String mac) { public Map<String, Object> getBoxPrivateKey(@RequestParam(value = "mac") String mac) {
try { 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); final TBoxOperation tBoxOperation = this.boxOperationService.getOne(queryWrapper);
if (tBoxOperation != null) { if (tBoxOperation != null) {
final String organId = tBoxOperation.getOrganId(); final String organId = tBoxOperation.getOrganId();
final TUser tUser = getcurUser(); final TUser tUser = getcurUser();
if (tUser != null && organId.equals(tUser.getOrgId())) { 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 jsonObject = new JSONObject();
jsonObject.put("key", tBoxOperation.getPrivateKey()); jsonObject.put("key", tBoxOperation.getPrivateKey());
return getResult(jsonObject); return getResult(jsonObject);
} else { } else {
return getFailResult("400", "您无权获取本单位机顶盒密钥"); return getFailResult("400", "您无权获取机顶盒密钥");
} }
} }
return getFailResult("500", "未查询到相关机顶盒信息"); return getFailResult("400", "系统未查询到此机顶盒相关信息");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -186,8 +204,8 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -186,8 +204,8 @@ public class ChinaMobileRestApiController extends BaseController {
return resultMap; return resultMap;
} }
//解密 //解密
mac=AESUtils.aesDecrypt(mac); mac = AESUtils.aesDecrypt(mac);
password= AESUtils.aesDecrypt(password); password = AESUtils.aesDecrypt(password);
if (!mac.equals(operation.getMac())) { if (!mac.equals(operation.getMac())) {
resultMap.put("resultCode", "400"); resultMap.put("resultCode", "400");
...@@ -354,11 +372,11 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -354,11 +372,11 @@ public class ChinaMobileRestApiController extends BaseController {
resultMap.put("data", list); resultMap.put("data", list);
return resultMap; return resultMap;
} catch (Exception e) { } catch (Exception e) {
resultMap.put("resultCode", "500"); resultMap.put("resultCode", "400");
resultMap.put("message", "该展板已下架"); resultMap.put("message", "该展板已下架");
resultMap.put("data", ""); resultMap.put("data", "");
} }
return getFailResult("该展板已下架"); return getFailResult("400", "该展板已下架");
} }
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
......
...@@ -201,12 +201,17 @@ public class FileUploadController extends BaseController { ...@@ -201,12 +201,17 @@ public class FileUploadController extends BaseController {
asset.setFileUrlCrypto(fileUrlCrypto); asset.setFileUrlCrypto(fileUrlCrypto);
asset.setFileCat(FileCatEnum.EXHIBITION_BOARD_DATUM.name()); asset.setFileCat(FileCatEnum.EXHIBITION_BOARD_DATUM.name());
asset.setLanguage(language); asset.setLanguage(language);
asset.setCrc32((long) crc32); if (Arrays.stream(VIDEO_TYPE).anyMatch(s -> Objects.equals(s, finalExtName.toUpperCase()))) {
asset.setCrc32((long) crc32);
}
asset.setCreateTime(createTime); asset.setCreateTime(createTime);
asset.setUpdateTime(createTime); asset.setUpdateTime(createTime);
if (one != null) { if (one != null) {
FastDFSUtils.deleteFile(fileUrl); try {
FastDFSUtils.deleteFile(fileUrlCrypto); FastDFSUtils.deleteFile(fileUrl);
FastDFSUtils.deleteFile(fileUrlCrypto);
} catch (Throwable ignored) {
}
asset.setFileUrl(one.getFileUrl()); asset.setFileUrl(one.getFileUrl());
asset.setFileUrlCrypto(one.getFileUrlCrypto()); asset.setFileUrlCrypto(one.getFileUrlCrypto());
} }
......
...@@ -148,6 +148,19 @@ public class BaseController implements Serializable { ...@@ -148,6 +148,19 @@ public class BaseController implements Serializable {
return map; 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 过滤相关字段 * JSON 过滤相关字段
* *
......
...@@ -9,8 +9,9 @@ ...@@ -9,8 +9,9 @@
<result column="mac" property="mac"/> <result column="mac" property="mac"/>
<result column="status" property="status"/> <result column="status" property="status"/>
<result column="area_id" property="areaId"/> <result column="area_id" property="areaId"/>
<result column="public_key" property="publicKey" /> <result column="public_key" property="publicKey"/>
<result column="private_key" property="privateKey" /> <result column="private_key" property="privateKey"/>
<result column="request_count" property="requestCount"/>
<result column="create_time" property="createTime"/> <result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/> <result column="update_time" property="updateTime"/>
<result column="organ_name" property="organName"/> <result column="organ_name" property="organName"/>
...@@ -22,7 +23,7 @@ ...@@ -22,7 +23,7 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <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> </sql>
<select id="getList" resultMap="BaseResultMap"> <select id="getList" resultMap="BaseResultMap">
...@@ -40,11 +41,12 @@ ...@@ -40,11 +41,12 @@
</select> </select>
<select id="selectBoxPage" resultMap="BaseResultMap"> <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 u.effective_date effective_date,u.exired_date exired_date
from t_box_operation b from t_box_operation b
left join t_organ o on b.organ_id = o.id left join t_organ o on b.organ_id = o.id
left join t_user u on u.org_id = b.organ_id and u.type = '3' and u.is_deleted = false left join t_user u on u.org_id = b.organ_id and u.type = '3' and u.is_deleted = false
left join t_area a on u.area_id = a.id left join t_area a on u.area_id = a.id
where 1=1 where 1=1
<if test="user.orgId!= null and user.orgId != '' "> <if test="user.orgId!= null and user.orgId != '' ">
...@@ -63,7 +65,7 @@ ...@@ -63,7 +65,7 @@
</select> </select>
<select id="selectPageList" resultMap="BaseResultMap"> <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 FROM t_box_operation b
left join t_organ r on r.id = b.organ_id 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' 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