mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
add 新增用户解绑个人桩接口
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
@@ -70,6 +71,31 @@ public class PersonPileController extends BaseController {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户解绑个人桩
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/userUnbindPile")
|
||||
public RestApiResponse<?> userUnbindPile(HttpServletRequest request, @RequestBody PileMemberBindingDTO dto) {
|
||||
logger.info("用户解绑个人桩信息 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
int i = pileService.userUnbindPile(dto);
|
||||
response = new RestApiResponse<>(i);
|
||||
} catch (BusinessException e) {
|
||||
logger.error("用户解绑个人桩 error, ", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("用户解绑个人桩 error, ", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_UNBIND_PILE_ERROR);
|
||||
}
|
||||
logger.info("用户解绑个人桩 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 个人桩管理员下发给其他用户
|
||||
*
|
||||
|
||||
@@ -49,11 +49,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -297,6 +293,34 @@ public class PileService {
|
||||
return pileMemberRelationService.insertPileMemberRelation(pileMemberRelation);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户解绑个人桩
|
||||
* @param dto
|
||||
*
|
||||
*/
|
||||
public int userUnbindPile(PileMemberBindingDTO dto) {
|
||||
// 查询该用户的身份,是管理员还是普通用户
|
||||
PileMemberRelation relation = new PileMemberRelation();
|
||||
relation.setPileSn(dto.getPileSn());
|
||||
relation.setMemberId(dto.getMemberId());
|
||||
PileMemberRelation pileMemberRelation = pileMemberRelationService.selectPileMemberRelation(relation);
|
||||
if (pileMemberRelation == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_THIS_PILE_INFO_IS_NULL);
|
||||
}
|
||||
String type = pileMemberRelation.getType();
|
||||
List<Integer> idList = new ArrayList<>();
|
||||
// 管理员解绑则会将此桩下面所有用户解绑
|
||||
if (StringUtils.equals(Constants.ONE, type)) {
|
||||
List<PileMemberRelation> pileMemberRelations = pileMemberRelationService.selectPileMemberRelationByPileSn(dto.getPileSn());
|
||||
idList = pileMemberRelations.stream().map(PileMemberRelation::getId).collect(Collectors.toList());
|
||||
}else {
|
||||
idList.add(pileMemberRelation.getId());
|
||||
}
|
||||
|
||||
return pileMemberRelationService.deleteRelationByIds(idList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人桩管理员下发给其他用户使用
|
||||
*
|
||||
|
||||
@@ -112,7 +112,7 @@ public enum ReturnCodeEnum {
|
||||
|
||||
CODE_NO_REAL_TIME_INFO("00400006", "未查到充电枪口实时信息"),
|
||||
|
||||
CODE_BINDING_PERSONAL_PILE_ERROR("00400007", "获取个人桩枪口实时数据异常"),
|
||||
CODE_BINDING_PERSONAL_PILE_ERROR("00400007", "绑定个人桩异常!"),
|
||||
|
||||
CODE_ADMIN_ISSUE_ERROR("00400008", "桩管理员下发个人桩异常"),
|
||||
|
||||
@@ -120,6 +120,10 @@ public enum ReturnCodeEnum {
|
||||
|
||||
CODE_GET_PERSONAL_PILE_CONNECTOR_INFO_ERROR("00400010", "获取个人桩枪口实时数据异常"),
|
||||
|
||||
CODE_THIS_PILE_INFO_IS_NULL("00400011", "未查到该桩信息!"),
|
||||
|
||||
CODE_UNBIND_PILE_ERROR("00400012", "解绑个人桩异常!"),
|
||||
|
||||
/* 个人桩 end */
|
||||
|
||||
CODE_THIS_CARNO_HAS_BEEN_BINDING("00500001", "当前车牌号已经绑定,请检查!"),
|
||||
|
||||
@@ -71,4 +71,5 @@ public interface PileMemberRelationMapper
|
||||
public int deletePileMemberRelationByIds(Integer[] ids);
|
||||
|
||||
|
||||
int deleteRelationByIds(List<Integer> ids);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,9 @@ public interface IPileMemberRelationService
|
||||
*/
|
||||
public int deletePileMemberRelationByIds(Integer[] ids);
|
||||
|
||||
|
||||
public int deleteRelationByIds(List<Integer> ids);
|
||||
|
||||
/**
|
||||
* 删除桩与用户绑定关系信息
|
||||
*
|
||||
|
||||
@@ -96,6 +96,11 @@ public class PileMemberRelationServiceImpl implements IPileMemberRelationService
|
||||
return pileMemberRelationMapper.deletePileMemberRelationByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteRelationByIds(List<Integer> ids) {
|
||||
return pileMemberRelationMapper.deleteRelationByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除桩与用户绑定关系信息
|
||||
*
|
||||
|
||||
@@ -85,5 +85,10 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<delete id="deleteRelationByIds">
|
||||
delete from pile_member_relation where id in
|
||||
<foreach item="id" collection="list" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user