InventoryController.java 2.77 KB
package com.ruoyi.service.controller;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.service.domain.Inventory;
import com.ruoyi.service.service.DepotService;
import com.ruoyi.service.service.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 库房盘点
 * 
 * @author ym
 */
@RestController
@RequestMapping("/service/inventory")
public class InventoryController extends BaseController
{

    @Resource
    private InventoryService inventoryService;

    @PreAuthorize("@ss.hasPermi('service:inventory:add')")
    @Log(title = "库房盘点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody Inventory inventory)
    {
        String selectType1=inventory.getSelectType1()==null?"":inventory.getSelectType1();
        String selectType2=inventory.getSelectType2()==null?"":inventory.getSelectType2();
        String selectType3=inventory.getSelectType3()==null?"":inventory.getSelectType3();
        String factory=selectType1+"&"+selectType2+"&"+selectType3;
        inventory.setFactor(factory);
        return toAjax(inventoryService.insert(inventory));
    }


    @PreAuthorize("@ss.hasPermi('service:inventory:edit')")
    @Log(title = "库房盘点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody Inventory inventory)
    {
        if (inventoryService.update(inventory) > 0)
        {
            return AjaxResult.success();
        }
        return AjaxResult.error("编辑失败,请联系管理员");
    }

    @PreAuthorize("@ss.hasPermi('service:inventory:remove')")
    @Log(title = "库房盘点", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        inventoryService.delete(ids);
        return success();
    }

    @PreAuthorize("@ss.hasPermi('service:inventory:list')")
    @GetMapping("/list")
    public TableDataInfo list(Inventory inventory)
    {
        startPage();
        List<Inventory> list = inventoryService.selectList(inventory);
        return getDataTable(list);
    }

}