package com.qianwen.smartman.modules.cps.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import java.util.List; import java.util.Map; import javax.validation.Valid; import com.qianwen.smartman.common.cache.RegionCache; import com.qianwen.smartman.common.constant.CommonConstant; import com.qianwen.smartman.common.enums.StatusType; import com.qianwen.core.boot.ctrl.BladeController; import com.qianwen.core.mp.support.Condition; import com.qianwen.core.mp.support.Query; import com.qianwen.core.scanner.modular.annotation.DeleteResource; import com.qianwen.core.scanner.modular.annotation.GetResource; import com.qianwen.core.scanner.modular.annotation.PostResource; import com.qianwen.core.scanner.modular.annotation.PutResource; import com.qianwen.core.scanner.modular.stereotype.ApiResource; import com.qianwen.core.secure.annotation.PreAuth; import com.qianwen.core.tool.api.R; import com.qianwen.core.tool.utils.Func; import com.qianwen.smartman.modules.cps.convert.StockInTypeConvert; import com.qianwen.smartman.modules.cps.entity.StockInType; import com.qianwen.smartman.modules.cps.service.IStockInTypeService; import com.qianwen.smartman.modules.cps.vo.StockInTypeVO; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; @Api(value = "StockInType管理", tags = {"StockInType管理"}) @ApiResource({"blade-cps/stock-in-type"}) @RestController /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/cps/controller/StockInTypeController.class */ public class StockInTypeController extends BladeController { private final IStockInTypeService stockInTypeService; public StockInTypeController(final IStockInTypeService stockInTypeService) { this.stockInTypeService = stockInTypeService; } @ApiOperationSupport(order = 1) @GetResource({"/get/{id}"}) @ApiOperation(value = "入库类型详情", notes = "传入stockInType") public R detail(@PathVariable String id) { StockInType stockInType = (StockInType) this.stockInTypeService.getById(id); return R.data(StockInTypeConvert.INSTANCE.convert(stockInType)); } @ApiOperationSupport(order = 2) @GetResource({"/list"}) @ApiOperation(value = "入库类型列表", notes = "传入map") public R> list(@RequestParam @ApiIgnore Map params) { List list = this.stockInTypeService.list(Condition.getQueryWrapper(params, StockInType.class)); return R.data(StockInTypeConvert.INSTANCE.convert(list)); } @ApiOperationSupport(order = 3) @GetResource({"/page"}) @ApiOperation(value = "入库类型分页", notes = "传入map") @PreAuth public R> page(Query query, @RequestParam(value = "key", required = false) String key, @RequestParam(value = "status", required = false) Integer status) { return R.data(this.stockInTypeService.pageStockInType(query, key, Func.isNull(status) ? CommonConstant.ENABLE : status)); } @ApiOperationSupport(order = 4) @PostResource({"/insert"}) @ApiOperation(value = "入库类型新增", notes = "传入stockInTypeVO") @PreAuth public R insert(@Valid @RequestBody StockInTypeVO stockInTypeVO) { StockInType stockInType = this.stockInTypeService.createStockInType(stockInTypeVO); return R.data(StockInTypeConvert.INSTANCE.convert(stockInType)); } @ApiOperationSupport(order = RegionCache.VILLAGE_LEVEL) @PutResource({"/update"}) @ApiOperation(value = "入库类型修改", notes = "传入stockInTypeVO") @PreAuth public R update(@Valid @RequestBody StockInTypeVO vo) { return R.data(this.stockInTypeService.updateStockIn(vo)); } @ApiOperationSupport(order = 6) @ApiOperation(value = "入库类型删除", notes = "传入ids") @PreAuth @DeleteResource({"/remove"}) public R remove(@ApiParam(value = "主键", required = true) @RequestBody List ids, @RequestParam("type") @ApiParam("删除传0 停用传1") Integer type) { if (ids.isEmpty()) { return R.status(false); } if (StatusType.REMOVE.getType().equals(type)) { return R.data(Boolean.valueOf(this.stockInTypeService.removeByIds(Func.toLongList(ids)))); } return R.data(Boolean.valueOf(this.stockInTypeService.changeStatus(Func.toLongList(ids), CommonConstant.DEACTIVATE))); } }