|
@@ -1,82 +1,82 @@
|
|
|
package org.jeecg.modules.basedata.controller;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URLDecoder;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.constant.CommonConstant;
|
|
|
+import org.jeecg.common.dto.basedata.ArchivesCollectionLineReqDTO;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
-import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.basedata.entity.BaseArchivesCollectionLine;
|
|
|
import org.jeecg.modules.basedata.service.IBaseArchivesCollectionLineService;
|
|
|
-
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-
|
|
|
-import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
-import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
-import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
-
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
-import org.springframework.web.servlet.ModelAndView;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-
|
|
|
- * @Title: Controller
|
|
|
- * @Description: 收付款条线档案
|
|
|
- * @author: jeecg-boot
|
|
|
- * @date: 2021-03-02
|
|
|
- * @version: V1.0
|
|
|
- */
|
|
|
+
|
|
|
+ * @Author jihaosen
|
|
|
+ * @date 2021/3/2
|
|
|
+ */
|
|
|
+ @Api("收付款条线档案接口")
|
|
|
@RestController
|
|
|
@RequestMapping("/basedata/baseArchivesCollectionLine")
|
|
|
@Slf4j
|
|
|
public class BaseArchivesCollectionLineController {
|
|
|
@Autowired
|
|
|
private IBaseArchivesCollectionLineService baseArchivesCollectionLineService;
|
|
|
-
|
|
|
-
|
|
|
- * 分页列表查询
|
|
|
- * @param baseArchivesCollectionLine
|
|
|
- * @param pageNo
|
|
|
- * @param pageSize
|
|
|
- * @param req
|
|
|
- * @return
|
|
|
- */
|
|
|
+
|
|
|
+ @ApiOperation(value = "分页查询", notes = "分页查询")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="pkOrg", value="组织",required=false, dataType="String"),
|
|
|
+ })
|
|
|
@GetMapping(value = "/list")
|
|
|
public Result<IPage<BaseArchivesCollectionLine>> queryPageList(BaseArchivesCollectionLine baseArchivesCollectionLine,
|
|
|
- @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
- @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
- HttpServletRequest req) {
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
Result<IPage<BaseArchivesCollectionLine>> result = new Result<IPage<BaseArchivesCollectionLine>>();
|
|
|
+ baseArchivesCollectionLine.setDelFlag(null);
|
|
|
QueryWrapper<BaseArchivesCollectionLine> queryWrapper = QueryGenerator.initQueryWrapper(baseArchivesCollectionLine, req.getParameterMap());
|
|
|
+ queryWrapper.eq("del_flag", CommonConstant.STATUS_NORMAL.toString());
|
|
|
+ queryWrapper.orderByAsc("create_time");
|
|
|
Page<BaseArchivesCollectionLine> page = new Page<BaseArchivesCollectionLine>(pageNo, pageSize);
|
|
|
IPage<BaseArchivesCollectionLine> pageList = baseArchivesCollectionLineService.page(page, queryWrapper);
|
|
|
result.setSuccess(true);
|
|
|
result.setResult(pageList);
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- * 添加
|
|
|
- * @param baseArchivesCollectionLine
|
|
|
- * @return
|
|
|
- */
|
|
|
+
|
|
|
+ @ApiOperation(value = "新增接口", notes = "新增收付款条线档案")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="pkOrg", value="组织",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="code", value="编码",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="name", value="名称",required=true, dataType="String"),
|
|
|
+ })
|
|
|
@PostMapping(value = "/add")
|
|
|
- public Result<BaseArchivesCollectionLine> add(@RequestBody BaseArchivesCollectionLine baseArchivesCollectionLine) {
|
|
|
+ public Result<BaseArchivesCollectionLine> add(@RequestBody BaseArchivesCollectionLine baseArchivesCollectionLine,
|
|
|
+ BindingResult bindingResult) {
|
|
|
Result<BaseArchivesCollectionLine> result = new Result<BaseArchivesCollectionLine>();
|
|
|
try {
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ if (bindingResult.hasErrors()){
|
|
|
+
|
|
|
+ bindingResult.getAllErrors().stream().forEach(error -> sb.append(error.getDefaultMessage() + "<br/>"));
|
|
|
+ result.error500(sb.toString());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
baseArchivesCollectionLineService.save(baseArchivesCollectionLine);
|
|
|
result.success("添加成功!");
|
|
|
} catch (Exception e) {
|
|
@@ -86,12 +86,14 @@ public class BaseArchivesCollectionLineController {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- * 编辑
|
|
|
- * @param baseArchivesCollectionLine
|
|
|
- * @return
|
|
|
- */
|
|
|
+
|
|
|
+ @ApiOperation(value = "编辑接口", notes = "编辑收付款条线档案")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="id", value="id",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="pkOrg", value="组织",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="code", value="编码",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="name", value="名称",required=true, dataType="String"),
|
|
|
+ })
|
|
|
@PutMapping(value = "/edit")
|
|
|
public Result<BaseArchivesCollectionLine> edit(@RequestBody BaseArchivesCollectionLine baseArchivesCollectionLine) {
|
|
|
Result<BaseArchivesCollectionLine> result = new Result<BaseArchivesCollectionLine>();
|
|
@@ -100,7 +102,6 @@ public class BaseArchivesCollectionLineController {
|
|
|
result.error500("未找到对应实体");
|
|
|
}else {
|
|
|
boolean ok = baseArchivesCollectionLineService.updateById(baseArchivesCollectionLine);
|
|
|
-
|
|
|
if(ok) {
|
|
|
result.success("修改成功!");
|
|
|
}
|
|
@@ -108,20 +109,23 @@ public class BaseArchivesCollectionLineController {
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- * 通过id删除
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
+
|
|
|
+ @ApiOperation(value = "删除接口", notes = "删除收付款条线档案")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="id", value="id",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="pkOrg", value="组织",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="code", value="编码",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="name", value="名称",required=true, dataType="String"),
|
|
|
+ })
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
- public Result<BaseArchivesCollectionLine> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
+ public Result<BaseArchivesCollectionLine> delete(@RequestBody ArchivesCollectionLineReqDTO reqDTO) {
|
|
|
Result<BaseArchivesCollectionLine> result = new Result<BaseArchivesCollectionLine>();
|
|
|
- BaseArchivesCollectionLine baseArchivesCollectionLine = baseArchivesCollectionLineService.getById(id);
|
|
|
+ BaseArchivesCollectionLine baseArchivesCollectionLine = baseArchivesCollectionLineService.getById(reqDTO.getId());
|
|
|
if(baseArchivesCollectionLine==null) {
|
|
|
result.error500("未找到对应实体");
|
|
|
}else {
|
|
|
- boolean ok = baseArchivesCollectionLineService.removeById(id);
|
|
|
+ baseArchivesCollectionLine.setDelFlag(CommonConstant.DEL_FLAG_1.toString());
|
|
|
+ boolean ok = baseArchivesCollectionLineService.updateById(baseArchivesCollectionLine);
|
|
|
if(ok) {
|
|
|
result.success("删除成功!");
|
|
|
}
|
|
@@ -129,29 +133,12 @@ public class BaseArchivesCollectionLineController {
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- * 批量删除
|
|
|
- * @param ids
|
|
|
- * @return
|
|
|
- */
|
|
|
- @DeleteMapping(value = "/deleteBatch")
|
|
|
- public Result<BaseArchivesCollectionLine> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
- Result<BaseArchivesCollectionLine> result = new Result<BaseArchivesCollectionLine>();
|
|
|
- if(ids==null || "".equals(ids.trim())) {
|
|
|
- result.error500("参数不识别!");
|
|
|
- }else {
|
|
|
- this.baseArchivesCollectionLineService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
- result.success("删除成功!");
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * 通过id查询
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "通过id查询接口", notes = "通过id查询收付款条线档案")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="id", value="id",required=true, dataType="String"),
|
|
|
+ })
|
|
|
@GetMapping(value = "/queryById")
|
|
|
public Result<BaseArchivesCollectionLine> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
Result<BaseArchivesCollectionLine> result = new Result<BaseArchivesCollectionLine>();
|
|
@@ -164,74 +151,4 @@ public class BaseArchivesCollectionLineController {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- * 导出excel
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- */
|
|
|
- @RequestMapping(value = "/exportXls")
|
|
|
- public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
|
|
-
|
|
|
- QueryWrapper<BaseArchivesCollectionLine> queryWrapper = null;
|
|
|
- try {
|
|
|
- String paramsStr = request.getParameter("paramsStr");
|
|
|
- if (oConvertUtils.isNotEmpty(paramsStr)) {
|
|
|
- String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
|
|
- BaseArchivesCollectionLine baseArchivesCollectionLine = JSON.parseObject(deString, BaseArchivesCollectionLine.class);
|
|
|
- queryWrapper = QueryGenerator.initQueryWrapper(baseArchivesCollectionLine, request.getParameterMap());
|
|
|
- }
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
- List<BaseArchivesCollectionLine> pageList = baseArchivesCollectionLineService.list(queryWrapper);
|
|
|
-
|
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, "收付款条线档案列表");
|
|
|
- mv.addObject(NormalExcelConstants.CLASS, BaseArchivesCollectionLine.class);
|
|
|
- mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("收付款条线档案列表数据", "导出人:Jeecg", "导出信息"));
|
|
|
- mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
- return mv;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * 通过excel导入数据
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
- public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
- Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
|
- for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
|
- MultipartFile file = entity.getValue();
|
|
|
- ImportParams params = new ImportParams();
|
|
|
- params.setTitleRows(2);
|
|
|
- params.setHeadRows(1);
|
|
|
- params.setNeedSave(true);
|
|
|
- try {
|
|
|
- List<BaseArchivesCollectionLine> listBaseArchivesCollectionLines = ExcelImportUtil.importExcel(file.getInputStream(), BaseArchivesCollectionLine.class, params);
|
|
|
- for (BaseArchivesCollectionLine baseArchivesCollectionLineExcel : listBaseArchivesCollectionLines) {
|
|
|
- baseArchivesCollectionLineService.save(baseArchivesCollectionLineExcel);
|
|
|
- }
|
|
|
- return Result.ok("文件导入成功!数据行数:" + listBaseArchivesCollectionLines.size());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage());
|
|
|
- return Result.error("文件导入失败!");
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- file.getInputStream().close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return Result.ok("文件导入失败!");
|
|
|
- }
|
|
|
-
|
|
|
}
|