package com.goafanti.weChat.controller;

import com.goafanti.common.bo.Result;
import com.goafanti.common.model.PublicAssistAdvice;
import com.goafanti.weChat.service.PublicAssistAdviceService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 公出协单意见表(PublicAssistAdvice)表控制层
 *
 * @author makejava
 * @since 2024-07-12 09:21:26
 */
@RestController
@RequestMapping("/api/admin/publicAssistAdvice")
public class PublicAssistAdviceController {
    /**
     * 服务对象
     */
    @Resource
    private PublicAssistAdviceService publicAssistAdviceService;


    /**
     * 新增数据
     *
     * @param publicAssistAdvice 实体
     * @return 新增结果
     */
    @PostMapping("/add")
    public Result add(PublicAssistAdvice publicAssistAdvice) {
        return new Result<>().data(this.publicAssistAdviceService.insert(publicAssistAdvice));
    }
    
    
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/get")
    public Result<PublicAssistAdvice> queryById( Integer id) {
        return new Result<>().data(this.publicAssistAdviceService.queryById(id));
    }



    /**
     * 编辑数据
     *
     * @param publicAssistAdvice 实体
     * @return 编辑结果
     */
    @PostMapping("/update")
    public Result edit(PublicAssistAdvice publicAssistAdvice) {
        return new Result<>().data(this.publicAssistAdviceService.update(publicAssistAdvice));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("/delete")
    public Result deleteById(Integer id) {
        return new Result<>().data(this.publicAssistAdviceService.deleteById(id));
    }



    /**
     * 公出协单意见列表
     * @return
     */
    @GetMapping("/list")
    public Result<PublicAssistAdvice> list(Integer id, Integer type) {
        if (type==null)type=0;
        return new Result<>().data(this.publicAssistAdviceService.list(id,type));
    }

}

