|  |  |  | 
|---|
|  |  |  | import com.vincent.rsf.server.manager.entity.StockItem; | 
|---|
|  |  |  | import com.vincent.rsf.server.manager.service.StockItemService; | 
|---|
|  |  |  | import com.vincent.rsf.server.system.controller.BaseController; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.security.access.prepost.PreAuthorize; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Api(tags = "库存明细") | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | public class StockItemController extends BaseController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private StockItemService stockItemService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stockItem:list')") | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stock:list')") | 
|---|
|  |  |  | @PostMapping("/stockItem/page") | 
|---|
|  |  |  | public R page(@RequestBody Map<String, Object> map) { | 
|---|
|  |  |  | BaseParam baseParam = buildParam(map, BaseParam.class); | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok().add(stockItemService.page(pageParam, pageParam.buildWrapper(true))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stockItem:list')") | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stock:list')") | 
|---|
|  |  |  | @PostMapping("/stockItem/list") | 
|---|
|  |  |  | public R list(@RequestBody Map<String, Object> map) { | 
|---|
|  |  |  | return R.ok().add(stockItemService.list()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stockItem:list')") | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stock:list')") | 
|---|
|  |  |  | @PostMapping({"/stockItem/many/{ids}", "/stockItems/many/{ids}"}) | 
|---|
|  |  |  | public R many(@PathVariable Long[] ids) { | 
|---|
|  |  |  | return R.ok().add(stockItemService.listByIds(Arrays.asList(ids))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stockItem:list')") | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stock:list')") | 
|---|
|  |  |  | @GetMapping("/stockItem/{id}") | 
|---|
|  |  |  | public R get(@PathVariable("id") Long id) { | 
|---|
|  |  |  | return R.ok().add(stockItemService.getById(id)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stockItem:save')") | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stock:save')") | 
|---|
|  |  |  | @OperationLog("Create 库存明细表") | 
|---|
|  |  |  | @PostMapping("/stockItem/save") | 
|---|
|  |  |  | public R save(@RequestBody StockItem stockItem) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok("Save Success").add(stockItem); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stockItem:update')") | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stock:update')") | 
|---|
|  |  |  | @OperationLog("Update 库存明细表") | 
|---|
|  |  |  | @PostMapping("/stockItem/update") | 
|---|
|  |  |  | public R update(@RequestBody StockItem stockItem) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok("Update Success").add(stockItem); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stockItem:remove')") | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stock:remove')") | 
|---|
|  |  |  | @OperationLog("Delete 库存明细表") | 
|---|
|  |  |  | @PostMapping("/stockItem/remove/{ids}") | 
|---|
|  |  |  | public R remove(@PathVariable Long[] ids) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok("Delete Success").add(ids); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stockItem:list')") | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stock:list')") | 
|---|
|  |  |  | @PostMapping("/stockItem/query") | 
|---|
|  |  |  | public R query(@RequestParam(required = false) String condition) { | 
|---|
|  |  |  | List<KeyValVo> vos = new ArrayList<>(); | 
|---|
|  |  |  | LambdaQueryWrapper<StockItem> wrapper = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | if (!Cools.isEmpty(condition)) { | 
|---|
|  |  |  | wrapper.like(StockItem::getMatnrk, condition); | 
|---|
|  |  |  | wrapper.like(StockItem::getMaktx, condition); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | stockItemService.page(new Page<>(1, 30), wrapper).getRecords().forEach( | 
|---|
|  |  |  | item -> vos.add(new KeyValVo(item.getId(), item.getMatnrk())) | 
|---|
|  |  |  | item -> vos.add(new KeyValVo(item.getId(), item.getMaktx())) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | return R.ok().add(vos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stockItem:list')") | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:stock:list')") | 
|---|
|  |  |  | @PostMapping("/stockItem/export") | 
|---|
|  |  |  | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { | 
|---|
|  |  |  | ExcelUtil.build(ExcelUtil.create(stockItemService.list(), StockItem.class), response); | 
|---|