| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.constants.AssetDeptConstant; |
| | | import com.ruoyi.system.query.AssetRepairRecordPageQuery; |
| | | import com.ruoyi.system.service.AssetRepairRecordService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.vo.asset.AssetRepairRecordPageVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | * @since 2025-09-15 |
| | | */ |
| | | @RestController |
| | | @Api(tags = {"资产维修记录相关接口"}) |
| | | @RequiredArgsConstructor(onConstructor_ = {@Lazy}) |
| | | @RequestMapping("/asset-repair-record") |
| | | public class AssetRepairRecordController { |
| | | |
| | | private final AssetRepairRecordService assetRepairRecordService; |
| | | private final ISysUserService sysUserService; |
| | | |
| | | @ApiOperation("获取维修记录分页列表") |
| | | @PostMapping("/page-list") |
| | | public R<IPage<AssetRepairRecordPageVO>> getRepairRecordPageList(@RequestBody AssetRepairRecordPageQuery pageQuery) { |
| | | // 数据权限:超级管理员/资产管理部查看所有数据,其他部门查看当前及下级部门的数据 |
| | | Long userId = SecurityUtils.getUserId(); |
| | | boolean isAdmin = SecurityUtils.isAdmin(userId); |
| | | |
| | | if (!isAdmin) { |
| | | try { |
| | | // 获取当前用户的部门名称 |
| | | String deptName = sysUserService.selectUserById(userId).getDept().getDeptName(); |
| | | |
| | | // 非超级管理员且非资产管理部,设置部门权限 |
| | | if (!AssetDeptConstant.ASSET_DEPARTMENT_NAME.equals(deptName)) { |
| | | pageQuery.setDeptId(Integer.valueOf(SecurityUtils.getLoginUser().getDeptId())); |
| | | } |
| | | } catch (Exception e) { |
| | | // 如果获取部门信息失败,默认设置部门权限 |
| | | try { |
| | | pageQuery.setDeptId(Integer.valueOf(SecurityUtils.getLoginUser().getDeptId())); |
| | | } catch (Exception ex) { |
| | | // ignore parse, leave null if cannot parse |
| | | } |
| | | } |
| | | } |
| | | |
| | | IPage<AssetRepairRecordPageVO> page = assetRepairRecordService.getRepairRecordPageList(pageQuery); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | } |
| | | |