Pu Zhibing
2024-12-11 dcd97d683792b5d47cc13966b24e3bbb92ee9854
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.Logical;
import com.ruoyi.common.security.annotation.RequiresPermissions;
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.util.StringUtils;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.ArrayList;
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;
    
    
    @RequiresPermissions(value = {"/invoiceType"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping("/pageList")
    @ApiOperation(value = "获取发票类型列表", tags = {"管理后台-发票类型管理"})
    public AjaxResult<PageInfo<TInvoiceType>> pageList(InvoiceTypePageList pageList){
        PageInfo<TInvoiceType> pageInfo = invoiceTypeService.pageList(pageList);
        return AjaxResult.success(pageInfo);
    }
    
    
    @RequiresPermissions(value = {"/invoiceManagement"}, logical = Logical.OR)
    @GetMapping("/pageListR")
    @ApiOperation(value = "获取开票公司和类型列表", tags = {"管理后台-发票管理"})
    public R<List<TInvoiceType>> pageListR(String invoicingCompany ){
        List<TInvoiceType> list = new ArrayList<>();
        if (StringUtils.hasLength(invoicingCompany )){
            list = invoiceTypeService.lambdaQuery().eq(TInvoiceType::getInvoicingCompany, invoicingCompany).list();
        }else{
            list = invoiceTypeService.lambdaQuery().list();
        }
        return R.ok(list);
    }
    
    
    @RequiresPermissions(value = {"/invoiceType/add"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping("/addInvoiceType")
    @ApiOperation(value = "添加发票类型", tags = {"管理后台-发票类型管理"})
    @Log(title = "【发票类型管理】添加发票类型", businessType = BusinessType.INSERT)
    public AjaxResult addInvoiceType(@RequestBody TInvoiceType invoiceType){
        invoiceTypeService.save(invoiceType);
        return AjaxResult.success();
    }
    
    
    
    @RequiresPermissions(value = {"/invoiceType/select", "/invoiceType/update"}, logical = Logical.OR)
    @ResponseBody
    @GetMapping("/getInvoiceTypeInfo/{id}")
    @ApiOperation(value = "获取发票类型详情", tags = {"管理后台-发票类型管理"})
    public AjaxResult<TInvoiceType> getInvoiceTypeInfo(@PathVariable Integer id){
        TInvoiceType invoiceType = invoiceTypeService.getById(id);
        return AjaxResult.success(invoiceType);
    }
    
    
    @RequiresPermissions(value = {"/invoiceType/update"}, logical = Logical.OR)
    @ResponseBody
    @PostMapping("/editInvoiceType")
    @ApiOperation(value = "编辑发票类型", tags = {"管理后台-发票类型管理"})
    @Log(title = "【发票类型管理】编辑发票类型", businessType = BusinessType.UPDATE)
    public AjaxResult editInvoiceType(@RequestBody TInvoiceType invoiceType){
        invoiceTypeService.updateById(invoiceType);
        return AjaxResult.success();
    }
    
    
    @RequiresPermissions(value = {"/invoiceType/del"}, logical = Logical.OR)
    @ResponseBody
    @DeleteMapping("/delInvoiceType")
    @ApiOperation(value = "删除发票类型", tags = {"管理后台-发票类型管理"})
    @Log(title = "【发票类型管理】删除发票类型", businessType = BusinessType.DELETE)
    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
    @GetMapping("/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);
    }
}