feat: 接口
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
package com.byhah.cloud.admin.module.website.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.byhah.cloud.admin.module.website.dto.WebsiteBaseInfoDto;
|
||||
import com.byhah.cloud.admin.module.website.service.WebsiteBaseInfoService;
|
||||
import com.byhah.cloud.basic.core.entity.website.WebsiteBaseInfo;
|
||||
import com.byhah.deploy.basic.validation.group.Insert;
|
||||
import com.byhah.deploy.basic.validation.group.Update;
|
||||
import com.byhah.deploy.starter.web.R;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 网站基础信息
|
||||
*
|
||||
* @author ZYJ
|
||||
*/
|
||||
@Tag(name = "网站基础信息")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/website/base")
|
||||
public class WebsiteBaseInfoController {
|
||||
|
||||
private final WebsiteBaseInfoService baseInfoService;
|
||||
|
||||
@Operation(summary = "编辑网站基础信息")
|
||||
@SaCheckPermission("website:base:save")
|
||||
@PostMapping("/edit")
|
||||
R<Void> edit(@RequestBody WebsiteBaseInfoDto dto) {
|
||||
baseInfoService.edit(dto);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "获取网站基础信息详情")
|
||||
@GetMapping("/detail")
|
||||
R<WebsiteBaseInfo> detail() {
|
||||
return R.ok(baseInfoService.detail());
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.byhah.cloud.admin.module.website.dto;
|
||||
|
||||
import com.byhah.cloud.basic.core.entity.website.WebsiteBaseInfo;
|
||||
import com.byhah.deploy.basic.validation.group.Insert;
|
||||
import com.byhah.deploy.basic.validation.group.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 网站基础信息编辑参数
|
||||
*
|
||||
* @author ZYJ
|
||||
**/
|
||||
@Data
|
||||
public class WebsiteBaseInfoDto {
|
||||
|
||||
@NotNull(message = "id不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "主页信息")
|
||||
private WebsiteBaseInfo.IndexInfo indexInfo;
|
||||
|
||||
@Schema(description = "硬件产品")
|
||||
private WebsiteBaseInfo.ProductInfo productInfo;
|
||||
|
||||
@Schema(description = "软件服务")
|
||||
private WebsiteBaseInfo.SoftwareInfo softwareInfo;
|
||||
|
||||
@Schema(description = "成功案例")
|
||||
private WebsiteBaseInfo.SuccessInfo successInfo;
|
||||
|
||||
@Schema(description = "关于我们")
|
||||
private WebsiteBaseInfo.AboutUsInfo aboutUsInfo;
|
||||
|
||||
@Schema(description = "联系信息")
|
||||
private WebsiteBaseInfo.ContactInfo contactInfo;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
|
||||
package com.byhah.cloud.admin.module.website.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.byhah.cloud.admin.module.website.dto.WebsiteBaseInfoDto;
|
||||
import com.byhah.cloud.basic.core.entity.website.WebsiteBaseInfo;
|
||||
import com.byhah.cloud.orm.mapper.website.IWebsiteBaseInfoMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 网站基础信息Service接口实现类
|
||||
*
|
||||
* @author ZYJ
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class WebsiteBaseInfoService extends ServiceImpl<IWebsiteBaseInfoMapper, WebsiteBaseInfo> {
|
||||
|
||||
public void edit(WebsiteBaseInfoDto dto) {
|
||||
WebsiteBaseInfo baseInfo = this.queryEntity();
|
||||
BeanUtil.copyProperties(dto, baseInfo);
|
||||
this.updateById(baseInfo);
|
||||
}
|
||||
|
||||
public WebsiteBaseInfo detail() {
|
||||
return this.queryEntity();
|
||||
}
|
||||
|
||||
public WebsiteBaseInfo queryEntity() {
|
||||
WebsiteBaseInfo baseInfo = lambdaQuery().one();
|
||||
if (Objects.isNull(baseInfo)) {
|
||||
baseInfo = new WebsiteBaseInfo();
|
||||
this.save(baseInfo);
|
||||
}
|
||||
return baseInfo;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user