xyc
2024-05-17 4a476243e0928236472f0a916467630cb5706ee5
modules/mainPart/src/main/java/com/zt/life/modules/mainPart/sysPictureBase/controller/SysPictureBaseController.java
@@ -50,7 +50,8 @@
    @ApiImplicitParams({
            @ApiImplicitParam(name = Constant.Q.ORDER_FIELD, value = Constant.QV.ORDER_FIELD, dataType = Constant.QT.STRING),
            @ApiImplicitParam(name = Constant.Q.ORDER, value = Constant.QV.ORDER, dataType = Constant.QT.STRING),
            @ApiImplicitParam(name = "productType", value = "检索关键字", dataType = Constant.QT.STRING, format = "CONTENT_TYPE^LK"), @ApiImplicitParam(name = "systemMark", value = "系统标识", dataType = Constant.QT.STRING, format = "SYSTEM_MARK^LK")})
            @ApiImplicitParam(name = "productType", value = "检索关键字", dataType = Constant.QT.STRING, format = "PRODUCT_TYPE^EQ"),
            @ApiImplicitParam(name = "systemMark", value = "系统标识", dataType = Constant.QT.STRING, format = "SYSTEM_MARK^LK")})
    public Result<List<SysPictureBase>> page(@ApiIgnore @QueryParam QueryFilter queryFilter) {
        return Result.ok(sysPictureBaseService.page(queryFilter));
@@ -66,31 +67,24 @@
    @PostMapping("save")
    @ApiOperation("保存")
    @LogOperation("保存")
    public Result save(@RequestBody MultipartFile file, Long id, Integer isDefault,
                       String name, String contentType, Integer productType,  String remark) {
        SysPictureBase sysPictureBase;
        if (id != 0) {
            sysPictureBase = sysPictureBaseService.get(id);
            sysPictureBase.setIsDefault(isDefault);
            sysPictureBase.setName(name);
            sysPictureBase.setContentType(contentType);
            sysPictureBase.setProductType(productType);
            sysPictureBase.setRemark(remark);
    public Result save(@RequestBody SysPictureBase sysPictureBase) {
        if (sysPictureBase.getId() != null) {
            sysPictureBaseService.update(sysPictureBase);
        } else {
            sysPictureBase = new SysPictureBase();
            sysPictureBase.setIsDefault(isDefault);
            sysPictureBase.setName(name);
            sysPictureBase.setContentType(contentType);
            sysPictureBase.setProductType(productType);
            sysPictureBase.setRemark(remark);
            sysPictureBaseService.insert(sysPictureBase);
        }
        if (sysPictureBase.getIsDefault()==1){
            sysPictureBaseService.updateByDefault(sysPictureBase.getId(),sysPictureBase.getProductType());
            sysPictureBaseService.updateProdeuctImg(sysPictureBase.getId(),sysPictureBase.getProductType());
            if (sysPictureBase.getId()==null){
                sysPictureBaseService.updateByDefault(sysPictureBase.getId(),sysPictureBase.getProductType());
                sysPictureBaseService.updateProdeuctImg(sysPictureBase.getId(),sysPictureBase.getProductType(),null);
            }else{
                if (!sysPictureBase.getId().equals(sysPictureBase.getId())){
                    sysPictureBaseService.updateByDefault(sysPictureBase.getId(),sysPictureBase.getProductType());
                    sysPictureBaseService.updateProdeuctImg(sysPictureBase.getId(),sysPictureBase.getProductType(),sysPictureBase.getId());
                }
            }
        }
        if (file != null) {
/*        if (file != null) {
            BufferedImage bufferedImage = null;
            try {
                String fileName = file.getOriginalFilename();
@@ -114,8 +108,7 @@
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        }*/
        return Result.ok();
    }
@@ -148,6 +141,26 @@
        }
    }
    @RequestMapping("/getSvgImage")
    public void getSvgImage(HttpServletResponse response, Long id) {
        try {
            SysPictureBase data = sysPictureBaseService.get(id);
            String svgContent = data.getSvgContent();
            response.setContentType("image/svg+xml");
            response.getWriter().write(svgContent);
            response.getWriter().flush();
            response.getWriter().close();
        }  catch (IOException e) {
            e.printStackTrace();
        }
    }
    @GetMapping("/getDefaultImg")
    public Result<SysPictureBase> getDefaultImg(Integer productType) {
        SysPictureBase data = sysPictureBaseService.getDefaultImg(productType);
        return Result.ok(data);
    }
    @DeleteMapping
    @ApiOperation("删除")
    @LogOperation("删除")