| | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.log.annotation.SysLog; |
| | | import com.by4cloud.platformx.device.constant.MaxSizeContant; |
| | | import com.by4cloud.platformx.device.entity.DeviceClass; |
| | | import com.by4cloud.platformx.device.entity.DeviceInventory; |
| | | import com.by4cloud.platformx.device.entity.MaxSize; |
| | | import com.by4cloud.platformx.device.service.DeviceClassService; |
| | | import com.by4cloud.platformx.device.service.JcMaxSizeService; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import com.by4cloud.platformx.common.excel.annotation.ResponseExcel; |
| | | import io.swagger.v3.oas.annotations.security.SecurityRequirement; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.Max; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | public class DeviceClassController { |
| | | |
| | | private final DeviceClassService deviceClassService; |
| | | private final JcMaxSizeService maxSizeService; |
| | | |
| | | /** |
| | | * 分页查询 |
| | |
| | | @PreAuthorize("@pms.hasPermission('platformx_deviceClass_view')" ) |
| | | public R getDeviceClassPage(@ParameterObject Page page, @ParameterObject DeviceClass deviceClass) { |
| | | LambdaQueryWrapper<DeviceClass> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.eq(StrUtil.isNotBlank(deviceClass.getName()),DeviceClass::getName,deviceClass.getName()); |
| | | wrapper.like(StrUtil.isNotBlank(deviceClass.getName()),DeviceClass::getName,deviceClass.getName()); |
| | | wrapper.eq(StrUtil.isNotBlank(deviceClass.getNumber()),DeviceClass::getNumber,deviceClass.getNumber()); |
| | | return R.ok(deviceClassService.page(page, wrapper)); |
| | | } |
| | |
| | | @GetMapping("/{id}" ) |
| | | public R getById(@PathVariable("id" ) Long id) { |
| | | DeviceClass byId = deviceClassService.getById(id); |
| | | byId.setParentId(byId.getPId().intValue()); |
| | | byId.setParentId(byId.getPId()); |
| | | return R.ok(byId); |
| | | } |
| | | |
| | |
| | | if(deviceClass.getParentId()==null){ |
| | | return R.failed("上级分类未选择!"); |
| | | } |
| | | deviceClass.setPId(deviceClass.getParentId().longValue()); |
| | | deviceClass.setNumber(maxSizeService.nextNo(MaxSizeContant.DEVICE_CLASS_NUM)); |
| | | deviceClass.setPId(deviceClass.getParentId()); |
| | | return R.ok(deviceClassService.save(deviceClass)); |
| | | } |
| | | |
| | |
| | | if(deviceClass.getParentId()==null){ |
| | | return R.failed("上级分类未选择!"); |
| | | } |
| | | deviceClass.setPId(deviceClass.getParentId().longValue()); |
| | | deviceClass.setPId(deviceClass.getParentId()); |
| | | return R.ok(deviceClassService.updateById(deviceClass)); |
| | | } |
| | | |