无关风月
2024-08-24 d0a2f8a17bb7888602f0f421bb01a765ef04fd29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package com.ruoyi.other.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.other.api.domain.TInvoiceType;
import com.ruoyi.other.query.InvoiceTypePageList;
import com.ruoyi.other.service.TInvoiceTypeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 无关风月
 * @since 2024-08-06
 */
@RestController
@RequestMapping("/t-invoice-type")
public class TInvoiceTypeController {
    
    @Resource
    private TInvoiceTypeService invoiceTypeService;
    
    
    @ResponseBody
    @GetMapping("/pageList")
    @ApiOperation(value = "获取发票类型列表", tags = {"管理后台-发票类型管理"})
    public AjaxResult<PageInfo<TInvoiceType>> pageList(InvoiceTypePageList pageList){
        PageInfo<TInvoiceType> pageInfo = invoiceTypeService.pageList(pageList);
        return AjaxResult.success(pageInfo);
    }
    
    
    @ResponseBody
    @PostMapping("/addInvoiceType")
    @ApiOperation(value = "添加发票类型", tags = {"管理后台-发票类型管理"})
    public AjaxResult addInvoiceType(@RequestBody TInvoiceType invoiceType){
        invoiceTypeService.save(invoiceType);
        return AjaxResult.success();
    }
    
    @ResponseBody
    @GetMapping("/getInvoiceTypeInfo/{id}")
    @ApiOperation(value = "获取发票类型详情", tags = {"管理后台-发票类型管理"})
    public AjaxResult<TInvoiceType> getInvoiceTypeInfo(@PathVariable Integer id){
        TInvoiceType invoiceType = invoiceTypeService.getById(id);
        return AjaxResult.success(invoiceType);
    }
    
    
    @ResponseBody
    @PostMapping("/editInvoiceType")
    @ApiOperation(value = "编辑发票类型", tags = {"管理后台-发票类型管理"})
    public AjaxResult editInvoiceType(@RequestBody TInvoiceType invoiceType){
        invoiceTypeService.updateById(invoiceType);
        return AjaxResult.success();
    }
    
    
    @ResponseBody
    @DeleteMapping("/delInvoiceType")
    @ApiOperation(value = "删除发票类型", tags = {"管理后台-发票类型管理"})
    public AjaxResult<TInvoiceType> delInvoiceType(Integer[] id){
        List<TInvoiceType> tInvoiceTypes = invoiceTypeService.listByIds(Arrays.asList(id));
        for (TInvoiceType invoiceType : tInvoiceTypes) {
            invoiceTypeService.removeById(invoiceType);
        }
        return AjaxResult.success();
    }
    
    
    
    @ResponseBody
    @DeleteMapping("/getInvoiceTypeList")
    @ApiOperation(value = "获取开票类型", tags = {"小程序-充电发票"})
    public AjaxResult<List<TInvoiceType>> getInvoiceTypeList(){
        List<TInvoiceType> list = invoiceTypeService.list(new LambdaQueryWrapper<TInvoiceType>()
                .eq(TInvoiceType::getDelFlag, 0).orderByAsc(TInvoiceType::getCreateTime));
        return AjaxResult.success(list);
    }
    
    
    /**
     * 根据id获取发票类型
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/getInvoiceType/{id}")
    public R<TInvoiceType> getInvoiceType(@PathVariable Integer id){
        TInvoiceType invoiceType = invoiceTypeService.getById(id);
        return R.ok(invoiceType);
    }
}