feat: 接口
This commit is contained in:
parent
6f8726000d
commit
6e31de7ac6
@ -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());
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
|
||||
package com.byhah.cloud.basic.core.entity.website;
|
||||
|
||||
import com.byhah.cloud.basic.core.entity.BaseEntity;
|
||||
import com.byhah.deploy.basic.core.annotation.PgJsonb;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 网站基础信息
|
||||
*
|
||||
* @author ZYJ
|
||||
**/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WebsiteBaseInfo extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -7870586325679198375L;
|
||||
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "主页信息")
|
||||
@PgJsonb
|
||||
private IndexInfo indexInfo;
|
||||
|
||||
@Schema(description = "硬件产品")
|
||||
@PgJsonb
|
||||
private ProductInfo productInfo;
|
||||
|
||||
@Schema(description = "软件服务")
|
||||
@PgJsonb
|
||||
private SoftwareInfo softwareInfo;
|
||||
|
||||
@Schema(description = "成功案例")
|
||||
@PgJsonb
|
||||
private SuccessInfo successInfo;
|
||||
|
||||
@Schema(description = "关于我们")
|
||||
@PgJsonb
|
||||
private AboutUsInfo aboutUsInfo;
|
||||
|
||||
@Schema(description = "联系信息")
|
||||
@PgJsonb
|
||||
private ContactInfo contactInfo;
|
||||
|
||||
@Data
|
||||
public static class IndexInfo {
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "标语图片地址")
|
||||
private String sloganUrl;
|
||||
|
||||
@Schema(description = "提供的服务集合")
|
||||
private List<String> services;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ProductInfo {
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String remark;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class SoftwareInfo {
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String remark;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class SuccessInfo {
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String remark;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class AboutUsInfo {
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "数量信息")
|
||||
private List<AboutUsInfoItem> items;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class AboutUsInfoItem {
|
||||
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "数量")
|
||||
private String num;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ContactInfo {
|
||||
|
||||
@Schema(description = "地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "联系电话信息")
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "邮箱信息")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "工作时间信息描述")
|
||||
private String workInfo;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
|
||||
package com.byhah.cloud.orm.mapper.website;
|
||||
|
||||
import com.byhah.cloud.autoconfigure.IBaseMapper;
|
||||
import com.byhah.cloud.basic.core.entity.system.SysUser;
|
||||
import com.byhah.cloud.basic.core.entity.website.WebsiteBaseInfo;
|
||||
|
||||
/**
|
||||
* 网站基础信息Mapper接口
|
||||
*
|
||||
* @author ZYJ
|
||||
**/
|
||||
public interface IWebsiteBaseInfoMapper extends IBaseMapper<WebsiteBaseInfo> {
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user