| | |
| | | package com.ruoyi.web.controller.zhang; |
| | | |
| | | |
| | | import com.qcloud.cos.utils.IOUtils; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | |
| | | import com.ruoyi.domain.ZfEconomy; |
| | | import com.ruoyi.domain.excel.ZfEconomyExcelBean; |
| | | import com.ruoyi.service.ZfEconomyService; |
| | | import com.ruoyi.service.impl.GetOrPut; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import lombok.val; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | |
| | | @Autowired |
| | | ZfEconomyService zfEconomyService; |
| | | |
| | | @Autowired |
| | | GetOrPut getOrPut; |
| | | |
| | | @GetMapping("cc") |
| | | public void ll() throws IOException { |
| | | List<ZfEconomy> change = zfEconomyService.change(); |
| | | for (ZfEconomy ch:change) { |
| | | if (ch.getUrl() != null) { |
| | | String[] splits = ch.getUrl().split(","); |
| | | StringBuilder list= new StringBuilder(); |
| | | for (int i=0;i<splits.length;i++) { |
| | | if (splits[i] != null && splits[i].length() !=0) { |
| | | // splits[i]=splits[i].replace("\\", "/"); |
| | | String cs = getOrPut.uploadWebFile("https://www.bendudu.com:8080/" + splits[i]); |
| | | if(i>=1) { |
| | | list.append(",").append(cs); |
| | | }else { |
| | | list.append(cs); |
| | | } |
| | | } |
| | | } |
| | | ch.setCosKey(list.toString()); |
| | | zfEconomyService.updateById(ch); |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/all") |
| | | public AjaxResult listAll(ZfEconomy zfEconomy){ |
| | | Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); |
| | |
| | | return zfEconomyService.selectDataList(zfEconomy, pageNum, pageSize); |
| | | } |
| | | |
| | | @GetMapping("/type") |
| | | public AjaxResult listType(){ |
| | | return zfEconomyService.listType(); |
| | | } |
| | | |
| | | /** |
| | | * 获取导入模板 |
| | | */ |
| | | @GetMapping("/model") |
| | | @PostMapping("/model") |
| | | public void getExportModel(HttpServletResponse response){ |
| | | List<ZfEconomyExcelBean> list = Collections.singletonList(new ZfEconomyExcelBean()); |
| | | ExcelUtil<ZfEconomyExcelBean> util = new ExcelUtil<>(ZfEconomyExcelBean.class); |
| | | util.exportExcel(response,list,"家庭收支台账记录数据"); |
| | | util.exportExcel(response,list,"家庭收支台账导入模板"); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void export(HttpServletResponse response, ZfEconomy zfEconomy) |
| | | { |
| | | List<ZfEconomy> list = zfEconomyService.selectByCondition(zfEconomy); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfEconomy> util = new ExcelUtil<>(ZfEconomy.class); |
| | | util.exportExcel(response, list, "家庭收支台账记录数据"); |
| | | } |
| | | /** |
| | | * 导出家庭收支台账记录列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:property:export')") |
| | | @Log(title = "家庭收支台账记录", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export1/{ids}") |
| | | public void export(HttpServletResponse response, @PathVariable Long[] ids) |
| | | { |
| | | List<ZfEconomy> list = zfEconomyService.selectByIds(ids); |
| | | log.info("导出记录为:{}",list); |
| | | ExcelUtil<ZfEconomy> util = new ExcelUtil<>(ZfEconomy.class); |
| | | util.exportExcel(response, list, "家庭收支台账记录数据"); |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ZfEconomy zfEconomy) |
| | | { |
| | | return zfEconomyService.addData2(zfEconomy); |
| | | return zfEconomyService.addData(zfEconomy); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ZfEconomy zfEconomy) |
| | | { |
| | | return toAjax(zfEconomyService.updateById(zfEconomy)); |
| | | return zfEconomyService.updateData(zfEconomy); |
| | | } |
| | | // |
| | | /** |
| | |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) |
| | | { |
| | | return toAjax(zfEconomyService.removeByIds(Arrays.asList(ids))); |
| | | return zfEconomyService.deleteData(ids); |
| | | } |
| | | |
| | | |