mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-08 03:50:13 +08:00
新增 绑定鉴权卡需密钥
This commit is contained in:
@@ -327,6 +327,12 @@ public class MemberController extends BaseController {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户解绑鉴权卡
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/memberUnbindingCard")
|
||||
public RestApiResponse<?> memberUnbindingCard(HttpServletRequest request, @RequestBody BindingCardDTO dto) {
|
||||
logger.info("用户解绑鉴权卡 param:{}", JSONObject.toJSONString(dto));
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@@ -289,6 +290,10 @@ public class MemberService {
|
||||
// memberId 不为空,说明此卡已被绑定
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_HAS_BEEN_BINDING);
|
||||
}
|
||||
if (!StringUtils.equals(pileAuthCardInfo.getSecretKey(), dto.getSecretKey().toUpperCase(Locale.ROOT))) {
|
||||
// 密钥不一致,不能绑定
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_SECRET_KEY_NOT_SAME);
|
||||
}
|
||||
authCard.setMemberId(dto.getMemberId());
|
||||
authCard.setStatus("1"); // 1-正常使用
|
||||
authCard.setCreateBy(dto.getMemberId());
|
||||
|
||||
@@ -109,4 +109,14 @@ public class PileAuthCardController extends BaseController {
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(pileAuthCardService.deletePileAuthCardByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 停用充电站鉴权卡
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('pile:card:edit')")
|
||||
@Log(title = "充电站鉴权卡", businessType = BusinessType.UPDATE)
|
||||
@GetMapping("/deactivateCard/{id}")
|
||||
public AjaxResult deactivateCard(@PathVariable("id") Long id) {
|
||||
return toAjax(pileAuthCardService.deactivateCard(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,8 @@ public enum ReturnCodeEnum {
|
||||
CODE_THIS_CARD_NOT_BIND_USER("00600002", "此卡未绑定用户!"),
|
||||
|
||||
CODE_THIS_CARD_HAS_BEEN_BINDING("00600003", "此卡已被绑定!"),
|
||||
|
||||
CODE_SECRET_KEY_NOT_SAME("00600004", "密钥错误,请检查!"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
|
||||
@@ -45,6 +45,8 @@ public class PileAuthCard {
|
||||
@Excel(name = "卡状态")
|
||||
private String status;
|
||||
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* 所属用户的会员id
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,11 @@ public class BindingCardDTO {
|
||||
*/
|
||||
private String physicsCard;
|
||||
|
||||
/**
|
||||
* 密钥
|
||||
*/
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* 电话号码
|
||||
*/
|
||||
|
||||
@@ -71,6 +71,13 @@ public interface PileAuthCardMapper {
|
||||
*/
|
||||
public int deletePileAuthCardById(Long id);
|
||||
|
||||
/**
|
||||
* 停用某张卡
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int deactivateCard(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除充电站鉴权卡
|
||||
*
|
||||
|
||||
@@ -88,5 +88,12 @@ public interface IPileAuthCardService {
|
||||
*/
|
||||
public int deletePileAuthCardById(Long id);
|
||||
|
||||
/**
|
||||
* 停用某张卡
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int deactivateCard(Long id);
|
||||
|
||||
int unBindingCard(PileAuthCard pileAuthCard);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.pile.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
@@ -9,6 +10,7 @@ import com.jsowell.pile.domain.MemberBasicInfo;
|
||||
import com.jsowell.pile.dto.PileAuthCardDTO;
|
||||
import com.jsowell.pile.service.IMemberBasicInfoService;
|
||||
import com.jsowell.pile.vo.web.PileAuthCardVO;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.jsowell.pile.mapper.PileAuthCardMapper;
|
||||
@@ -109,10 +111,12 @@ public class PileAuthCardServiceImpl implements IPileAuthCardService {
|
||||
}
|
||||
memberBasicInfo.setStatus("1"); // 1-正常使用
|
||||
}
|
||||
String secretKey = RandomStringUtils.randomAlphanumeric(8).toUpperCase(Locale.ROOT); // 生成8位数的字母 + 数字随机数
|
||||
PileAuthCard pileAuthCard = PileAuthCard.builder()
|
||||
.logicCard(dto.getLogicCard())
|
||||
.memberId(memberBasicInfo.getMemberId())
|
||||
.status(memberBasicInfo.getStatus())
|
||||
.secretKey(secretKey)
|
||||
.build();
|
||||
return pileAuthCardMapper.insertPileAuthCard(pileAuthCard);
|
||||
}
|
||||
@@ -167,6 +171,11 @@ public class PileAuthCardServiceImpl implements IPileAuthCardService {
|
||||
return pileAuthCardMapper.deletePileAuthCardById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deactivateCard(Long id) {
|
||||
return pileAuthCardMapper.deactivateCard(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int unBindingCard(PileAuthCard pileAuthCard) {
|
||||
return pileAuthCardMapper.unBindingCard(pileAuthCard);
|
||||
|
||||
@@ -20,6 +20,8 @@ public class PileAuthCardVO {
|
||||
|
||||
private String status;
|
||||
|
||||
private String secretKey;
|
||||
|
||||
private String createTime;
|
||||
|
||||
private String memberId;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<result property="logicCard" column="logic_card" />
|
||||
<result property="physicsCard" column="physics_card" />
|
||||
<result property="status" column="status" />
|
||||
<result property="secretKey" column="secret_key" />
|
||||
<result property="memberId" column="member_id" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
@@ -18,11 +19,11 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPileAuthCardVo">
|
||||
select id, logic_card, physics_card, status, member_id, create_time, create_by, update_time, update_by, del_flag from pile_auth_card
|
||||
select id, logic_card, physics_card, status, secret_key, member_id, create_time, create_by, update_time, update_by, del_flag from pile_auth_card
|
||||
</sql>
|
||||
|
||||
<sql id="Base_Column_List" >
|
||||
id, logic_card, physics_card, status, member_id, create_time, create_by, update_time, update_by, del_flag
|
||||
id, logic_card, physics_card, status, secret_key, member_id, create_time, create_by, update_time, update_by, del_flag
|
||||
</sql>
|
||||
|
||||
<select id="selectPileAuthCardList" parameterType="com.jsowell.pile.domain.PileAuthCard" resultMap="PileAuthCardResult">
|
||||
@@ -31,6 +32,7 @@
|
||||
<if test="logicCard != null and logicCard != ''"> and logic_card = #{logicCard}</if>
|
||||
<if test="physicsCard != null and physicsCard != ''"> and physics_card = #{physicsCard}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="secretKey != null and secretKey != ''"> and secret_key = #{secretKey}</if>
|
||||
<if test="memberId != null and memberId != ''"> and member_id = #{memberId}</if>
|
||||
</where>
|
||||
</select>
|
||||
@@ -46,6 +48,7 @@
|
||||
t1.logic_card as logicCard,
|
||||
t1.physics_card as physicsCard,
|
||||
t1.status,
|
||||
t1.secret_key as secretKey,
|
||||
t1.create_time as createTime,
|
||||
t1.member_id as memberId,
|
||||
t2.mobile_number as phoneNumber,
|
||||
@@ -63,6 +66,7 @@
|
||||
<if test="logicCard != null">logic_card,</if>
|
||||
<if test="physicsCard != null">physics_card,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="secretKey != null">secret_key,</if>
|
||||
<if test="memberId != null">member_id,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
@@ -74,6 +78,7 @@
|
||||
<if test="logicCard != null">#{logicCard},</if>
|
||||
<if test="physicsCard != null">#{physicsCard},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="secretKey != null">#{secretKey},</if>
|
||||
<if test="memberId != null">#{memberId},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
@@ -102,6 +107,12 @@
|
||||
delete from pile_auth_card where id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="deactivateCard" parameterType="Long">
|
||||
update pile_auth_card
|
||||
set status = '9'
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
|
||||
<delete id="deletePileAuthCardByIds" parameterType="String">
|
||||
delete from pile_auth_card where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
@@ -139,6 +150,7 @@
|
||||
t1.logic_card as logicCard,
|
||||
t1.physics_card as physicsCard,
|
||||
t1.status,
|
||||
t1.secret_key as secretKey,
|
||||
t1.create_time as createTime,
|
||||
t1.member_id as memberId,
|
||||
t2.mobile_number as phoneNumber,
|
||||
|
||||
@@ -42,3 +42,11 @@ export function delCard(id) {
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 停用某张卡
|
||||
export function deactivateCard(id){
|
||||
return request({
|
||||
url: '/pile/card/deactivateCard/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@
|
||||
:value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="密钥" align="center" prop="secretKey" />
|
||||
<!-- <el-table-column label="物理卡号" align="center" prop="physicsCard" />-->
|
||||
<el-table-column label="所属用户" align="center" prop="nickName" >
|
||||
<template slot-scope="scope">
|
||||
@@ -112,8 +113,8 @@
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
icon="el-icon-circle-close"
|
||||
@click="handleDeactivateCard(scope.row)"
|
||||
v-hasPermi="['pile:card:remove']"
|
||||
>停用</el-button>
|
||||
</template>
|
||||
@@ -170,7 +171,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listCard, getCard, delCard, addCard, updateCard } from "@/api/pile/card";
|
||||
import {listCard, getCard, delCard, addCard, updateCard, deactivateCard} from "@/api/pile/card";
|
||||
|
||||
export default {
|
||||
name: "card",
|
||||
@@ -314,6 +315,17 @@ export default {
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
|
||||
// 停用按钮
|
||||
handleDeactivateCard(row) {
|
||||
const id = row.id;
|
||||
this.$modal.confirm('是否确认停用卡号为"' + row.logicCard + '"的鉴权卡?').then(function() {
|
||||
return deactivateCard(id);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("停用成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('pile/card/export', {
|
||||
|
||||
Reference in New Issue
Block a user