完成删除接口

修改刷卡系统查询卡授权设备列表接口,给返回列表增加返回id字段
This commit is contained in:
wen 2022-01-26 11:14:11 +08:00
parent 5974bf6ee3
commit 1852958fcb
7 changed files with 81 additions and 6 deletions

View File

@ -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<Object> deleteDevice(@PathVariable("deviceId") Integer deviceId) {
return xhpcCardService.deleteDevice(deviceId);
}
}

View File

@ -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;

View File

@ -21,10 +21,32 @@ public interface TIccardDeviceMapper {
/**
* 查询所有记录
*
* @return 返回一个装着所有记录的集合
* @author WH
* @date 2022/1/25 17:07
* @since version-1.0
*/
List<TIccardDevice> 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);
}

View File

@ -13,7 +13,7 @@ import java.util.Date;
@Data
public class TIccardDevice implements Serializable {
private Integer id;
private Long id;
/**
* 设备名称

View File

@ -28,4 +28,15 @@ public interface IXhpcCardService {
*/
R<ListOfAuthorizedDevices> queryDeviceList();
/**
* 逻辑删除指定卡授权设备
*
* @param deviceId 卡授权设备id
* @return 返回Result结果集对象
* @author WH
* @date 2022/1/26 10:39
* @since version-1.0
*/
R<Object> deleteDevice(Integer deviceId);
}

View File

@ -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<Object> 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();
}
}

View File

@ -26,6 +26,13 @@
select
<include refid="Base_Column_List"/>
from t_iccard_device
where del_flag = 0
</select>
<select id="selectDeletedStatusByDeviceId" resultType="com.xhpc.card.pojo.TIccardDevice">
select
<include refid="Base_Column_List"/>
from t_iccard_device
where del_flag = 1 and id = #{deviceId}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete
@ -117,4 +124,9 @@
tenant_id = #{tenantId,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateCardDeviceStatusIsDel">
update t_iccard_device
set del_flag = 1
where serialNumber = #{deviceId}
</update>
</mapper>