xuhy
2026-03-02 9da3041d5a71f30a0f0f9dc005ffc4af88ef7bec
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
134
135
package com.ruoyi.web.controller.api;
 
 
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.WebUtils;
import com.ruoyi.system.export.TChildcareServicesExport;
import com.ruoyi.system.export.TMicroWishExport;
import com.ruoyi.system.model.TChildcareServices;
import com.ruoyi.system.query.TChildcareServicesQuery;
import com.ruoyi.system.query.TCourseOrderQuery;
import com.ruoyi.system.service.TChildcareServicesService;
import com.ruoyi.system.vo.TChildcareServicesVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Objects;
 
/**
 * <p>
 * 托育服务需求 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-11-06
 */
@Api(tags = "托育服务需求管理")
@RestController
@RequestMapping("/t-childcare-services")
public class TChildcareServicesController {
 
    private final TChildcareServicesService childcareServicesService;
    @Autowired
    public TChildcareServicesController(TChildcareServicesService childcareServicesService) {
        this.childcareServicesService = childcareServicesService;
    }
 
    /**
     * 获取托育服务需求管理管理列表
     */
    @ApiOperation(value = "获取托育服务需求管理分页列表")
    @PostMapping(value = "/pageList")
    public R<PageInfo<TChildcareServicesVO>> pageList(@RequestBody TChildcareServicesQuery query) {
        return R.ok(childcareServicesService.pageList(query));
    }
 
    /**
     * 获取托育服务需求管理管理列表
     */
    @ApiOperation(value = "获取托育服务需求管理列表")
    @PostMapping(value = "/list")
    public R<List<TChildcareServices>> list() {
        return R.ok(childcareServicesService.list(Wrappers.lambdaQuery(TChildcareServices.class).orderByDesc(TChildcareServices::getCreateTime)));
    }
 
    /**
     * 查看托育服务需求管理详情
     */
    @ApiOperation(value = "查看托育服务需求管理详情")
    @GetMapping(value = "/getDetailById")
    public R<TChildcareServices> getDetailById(@RequestParam String id) {
        return R.ok(childcareServicesService.getById(id));
    }
 
    /**
     * 删除托育服务需求管理
     */
    @Log(title = "托育服务需求管理信息-删除托育服务需求管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除托育服务需求管理")
    @DeleteMapping(value = "/deleteById")
    public R<Boolean> deleteById(@RequestParam String id) {
        return R.ok(childcareServicesService.removeById(id));
    }
 
    /**
     * 批量删除托育服务需求管理
     */
    @Log(title = "托育服务需求管理信息-删除托育服务需求管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "批量删除托育服务需求管理")
    @DeleteMapping(value = "/deleteByIds")
    public R<Boolean> deleteByIds(@RequestBody List<String> ids) {
        return R.ok(childcareServicesService.removeByIds(ids));
    }
 
    @Log(title = "托育服务需求管理信息-托育服务导出", businessType = BusinessType.EXPORT)
    @ApiOperation(value = "托育服务导出")
    @PostMapping("/exportChildcareServices")
    public void exportChildcareServices(@RequestBody TChildcareServicesQuery query){
        List<TChildcareServicesExport> childcareServicesExports = childcareServicesService.exportChildcareServices(query);
        for (TChildcareServicesExport microWishExport : childcareServicesExports) {
            if(Objects.nonNull(microWishExport.getCreateTime())){
                microWishExport.setCreateTimeStr(DateUtils.localDateTimeToString(microWishExport.getCreateTime()));
            }
        }
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TChildcareServicesExport.class, childcareServicesExports);
        HttpServletResponse response = WebUtils.response();
        assert response != null;
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        ServletOutputStream outputStream = null;
        try {
            String fileName = URLEncoder.encode("托育服务导出.xls", "utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            outputStream = response.getOutputStream();
            workbook.write(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
 
}