diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardController.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardController.java index 9a26698e..351b2ed1 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardController.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardController.java @@ -6,10 +6,7 @@ import com.xhpc.common.core.domain.R; import com.xhpc.common.core.web.controller.BaseController; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * @author yuyang @@ -43,5 +40,18 @@ public class XhpcCardController extends BaseController { return xhpcCardService.queryDeviceList(); } + /** + * 逻辑删除指定的卡授权设备 + * + * @author WH + * @date 2022/1/26 10:37 + * @since version-1.0 + */ + @DeleteMapping("/devices/{deviceId}") + public R deleteDevice(@PathVariable("deviceId") Integer deviceId) { + + return xhpcCardService.deleteDevice(deviceId); + } + } diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/ListOfAuthorizedDevices.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/ListOfAuthorizedDevices.java index e1e96a8b..7bc1c89a 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/ListOfAuthorizedDevices.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/ListOfAuthorizedDevices.java @@ -36,6 +36,11 @@ public class ListOfAuthorizedDevices { @Data public static class DataDTO { + /** + * deviceId + */ + @JsonProperty("deviceId") + private Long deviceId; /** * deviceNumber */ @@ -57,7 +62,7 @@ public class ListOfAuthorizedDevices { @JsonProperty("grantOperator") private String grantOperator; /** - * 授权给谁的,0运营商,1平台 + * 授权给谁的,0表示运营商,1表示平台 */ @JsonProperty("type") private Integer type; diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/TIccardDeviceMapper.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/TIccardDeviceMapper.java index 8bf8c41f..b52f6dd1 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/TIccardDeviceMapper.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/TIccardDeviceMapper.java @@ -21,10 +21,32 @@ public interface TIccardDeviceMapper { /** * 查询所有记录 * + * @return 返回一个装着所有记录的集合 * @author WH * @date 2022/1/25 17:07 * @since version-1.0 */ List selectAll(); + /** + * 更新卡授权设备为删除状态 + * + * @param deviceId the id of card grant device + * @author WH + * @date 2022/1/26 10:48 + * @since version-1.0 + */ + void updateCardDeviceStatusIsDel(Integer deviceId); + + /** + * query specified card grant device delete status + * + * @param deviceId specified card grant device id + * @return specified card grant device record + * @author WH + * @date 2022/1/26 11:03 + * @since version-1.0 + */ + TIccardDevice selectDeletedStatusByDeviceId(Integer deviceId); + } \ No newline at end of file diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/pojo/TIccardDevice.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/pojo/TIccardDevice.java index f8ae38d7..3b9e31cf 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/pojo/TIccardDevice.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/pojo/TIccardDevice.java @@ -13,7 +13,7 @@ import java.util.Date; @Data public class TIccardDevice implements Serializable { - private Integer id; + private Long id; /** * 设备名称 diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardService.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardService.java index f7b86d2c..c5c03be6 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardService.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardService.java @@ -28,4 +28,15 @@ public interface IXhpcCardService { */ R queryDeviceList(); + /** + * 逻辑删除指定卡授权设备 + * + * @param deviceId 卡授权设备id + * @return 返回Result结果集对象 + * @author WH + * @date 2022/1/26 10:39 + * @since version-1.0 + */ + R deleteDevice(Integer deviceId); + } diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java index 522296d2..46a80712 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java @@ -92,6 +92,7 @@ public class XhpcCardServiceImpl implements IXhpcCardService { } for (TIccardDevice tIccardDevice : tIccardDeviceList) { ListOfAuthorizedDevices.DataDTO dataDTO = new ListOfAuthorizedDevices.DataDTO(); + dataDTO.setDeviceId(tIccardDevice.getId()); dataDTO.setDeviceName(tIccardDevice.getDevname()); dataDTO.setDeviceType(tIccardDevice.getDevtype()); dataDTO.setDeviceNumber(tIccardDevice.getSerialnumber()); @@ -102,4 +103,18 @@ public class XhpcCardServiceImpl implements IXhpcCardService { return R.ok(listOfAuthorizedDevices); } + @Override + public R deleteDevice(Integer deviceId) { + + if (deviceId == null) { + return R.fail("deviceId为null"); + } + TIccardDevice tIccardDevice = tIccardDeviceMapper.selectDeletedStatusByDeviceId(deviceId); + if (tIccardDevice != null) { + return R.fail(404, "指定资源不存在"); + } + tIccardDeviceMapper.updateCardDeviceStatusIsDel(deviceId); + return R.ok(); + } + } diff --git a/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardDeviceMapper.xml b/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardDeviceMapper.xml index 0f4ad3f2..4de0f1b8 100644 --- a/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardDeviceMapper.xml +++ b/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardDeviceMapper.xml @@ -26,6 +26,13 @@ select from t_iccard_device + where del_flag = 0 + + delete @@ -117,4 +124,9 @@ tenant_id = #{tenantId,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} + + update t_iccard_device + set del_flag = 1 + where serialNumber = #{deviceId} + \ No newline at end of file