Newer
Older
huludao / src / main / java / com / newfiber / modules / inspection / controller / EquTechnologicalProcessTemplateController.java
package com.newfiber.modules.inspection.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.newfiber.common.utils.R;
import com.newfiber.modules.inspection.entity.EquTechnologicalProcessTemplateEntity;
import com.newfiber.modules.inspection.service.EquTechnologicalProcessTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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;

import java.util.List;
import java.util.Map;
import java.util.UUID;


/**
 * 设备工单审批模版信息表
 *
 * @author xiey
 * @email sunlightcs@gmail.com
 * @date 2020-09-10 19:16:42
 */
@RestController
@RequestMapping("equtechnologicalprocesstemplate")
@Api(tags = "设备工单审批模版信息")
public class EquTechnologicalProcessTemplateController {
    @Autowired
    private EquTechnologicalProcessTemplateService equTechnologicalProcessTemplateService;

    /**
     * 列表
     */
    @PostMapping("/list")
    @ApiOperation("审批模版信息列表")
    //@RequiresPermissions("business:equtechnologicalprocesstemplate:list")
    public R list() {
        List<Map<String, Object>> list = equTechnologicalProcessTemplateService.queryList();

        return R.ok().put("list", list);
    }

    /**
     * 批量保存
     */
    @PostMapping("/save")
    @ApiOperation("保存审批模版信息")
    //@RequiresPermissions("business:equtechnologicalprocesstemplate:save")
    public R save(@RequestBody List<EquTechnologicalProcessTemplateEntity> entities) {
        String uuid = UUID.randomUUID().toString().replace("-", "");
        for (EquTechnologicalProcessTemplateEntity entity : entities) {
            entity.setTemplateNo(uuid);
        }
        equTechnologicalProcessTemplateService.saveBatch(entities);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation("修改审批模版信息")
    //@RequiresPermissions("business:equtechnologicalprocesstemplate:update")
    public R update(@RequestBody List<EquTechnologicalProcessTemplateEntity> entities) {

        equTechnologicalProcessTemplateService.remove(new QueryWrapper<EquTechnologicalProcessTemplateEntity>()
                .eq("template_no", entities.get(0).getTemplateNo()));

        equTechnologicalProcessTemplateService.saveBatch(entities);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation("删除审批模版信息")
    //@RequiresPermissions("business:equtechnologicalprocesstemplate:delete")
    public R delete(@RequestBody String templateNo) {
        equTechnologicalProcessTemplateService.remove(new QueryWrapper<EquTechnologicalProcessTemplateEntity>()
                .eq("template_no", templateNo));

        return R.ok();
    }

}