EquipmentBindSparepartController.java 2.6 KB
package com.skua.modules.equipment.controller;


import javax.servlet.http.HttpServletRequest;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.modules.equipment.entity.EquipmentBindSparepart;
import com.skua.modules.equipment.entity.EquipmentSparepart;
import com.skua.modules.equipment.service.IEquipmentBindSparepartService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * <pre>
 * 设备关联备品备件
 * </pre>
 * @author 开发者姓名
 * @version V0.1, 开发时间
 */
@Slf4j
@Api(tags="设备关联备品备件")
@RestController("webEquipmentBindSparepartController")
@RequestMapping("/web/equipment/equipmentBindSparepart")
public class EquipmentBindSparepartController {
	@Autowired
	private IEquipmentBindSparepartService equipmentBindSparepartService;

	@AutoLog(value = "设备关联备品备件-分页列表查询")
	@ApiOperation(value="设备关联备品备件-分页列表查询", notes="设备关联备品备件-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<EquipmentSparepart>> queryPageList(
			@RequestParam(name="equipmentId", defaultValue="1") String equipmentId,
			@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
			@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
			HttpServletRequest req) {
		Result<IPage<EquipmentSparepart>> result = new Result<IPage<EquipmentSparepart>>();

		Page<EquipmentSparepart> page = new Page<EquipmentSparepart>(pageNo, pageSize);
		IPage<EquipmentSparepart> pageList = equipmentBindSparepartService.querySparepartListByEquipmentId(page,equipmentId);
		result.setSuccess(true);
		result.setResult(pageList);
		return result;
	}


	@AutoLog(value = "设备关联备品备件-添加修改")
	@ApiOperation(value="设备关联备品备件-添加修改", notes="设备关联备品备件-添加修改")
	@PostMapping(value = "/saveOrUpdate")
	public Result<EquipmentBindSparepart> saveOrUpdate(@RequestBody EquipmentBindSparepart equipmentBindSparepart) {
		Result<EquipmentBindSparepart> result = new Result<EquipmentBindSparepart>();
		try {
			equipmentBindSparepartService.updateEquipmentBindSparepart(equipmentBindSparepart);
			result.success("添加成功!");
		} catch (Exception e) {
			log.error(e.getMessage(),e);
			result.error500("操作失败");
		}
		return result;
	}

}