在线h5开发

This commit is contained in:
Github_lizhw 2026-03-21 23:38:23 +08:00
parent ecc03127bc
commit 5e619f7924
5 changed files with 54 additions and 4 deletions

View File

@ -7,7 +7,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConditionalOnProperty(prefix = "tenant", value = "enabled", havingValue = "true")
@ConditionalOnProperty(prefix = "tenant", value = "enable", havingValue = "true")
public class MybatisPlusAutoConfigTenant {
@Bean

View File

@ -139,9 +139,30 @@ public class H5ProjectController {
}
h5Project.setStatus(status);
return h5ProjectService.updateById(h5Project);
return h5ProjectService.updateStatus(id, status);
}
/**
* 更新H5项目状态
*
* @param id H5项目ID
* @return 是否更新成功
*/
@Operation(summary = "更新H5项目状态")
@PostMapping("/updateContent")
public Boolean updateContent(@RequestParam Long id, @RequestBody H5ProjectContentDTO contentDTO) {
H5Project h5Project = h5ProjectService.getById(id);
if (h5Project == null) {
throw new ServiceException("项目不存在");
}
Long currentUserId = LoginHelper.getUserId();
if (!currentUserId.equals(h5Project.getCreatedBy())) {
throw new ServiceException("无权限操作此项目");
}
return h5ProjectService.updateContent(id, contentDTO);
}
/**
* 删除H5项目
*

View File

@ -69,6 +69,10 @@ public interface H5ProjectService extends IService<H5Project> {
*/
List<Long> getProjectGroupIds(Long projectId);
boolean updateContent(Long projectId, H5ProjectContentDTO content);
boolean updateStatus(Long projectId, Integer status);
/**
* 获取项目内容
*

View File

@ -2,6 +2,7 @@ package com.luban.api.service.impl;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -12,6 +13,7 @@ import com.luban.api.entity.H5ProjectGroup;
import com.luban.api.dto.H5ProjectContentDTO;
import com.luban.api.dto.query.H5ProjectQueryDTO;
import com.luban.api.service.H5ProjectService;
import com.luban.api.util.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -32,6 +34,9 @@ public class H5ProjectServiceImpl extends ServiceImpl<H5ProjectDao, H5Project> i
@Autowired
private H5ProjectGroupDao h5ProjectGroupDao;
@Autowired
private JSON json;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveH5ProjectWithContent(H5Project h5Project, H5ProjectContentDTO content, List<Long> groupIds) {
@ -82,6 +87,26 @@ public class H5ProjectServiceImpl extends ServiceImpl<H5ProjectDao, H5Project> i
return this.getById(id);
}
@Override
public boolean updateContent(Long projectId, H5ProjectContentDTO content) {
if (projectId == null || content == null) {
return false;
}
return this.update(new LambdaUpdateWrapper<H5Project>()
.eq(H5Project::getId, projectId)
.set(H5Project::getContent, json.toJSON(content)));
}
@Override
public boolean updateStatus(Long projectId, Integer status) {
if (projectId == null || status == null) {
return false;
}
return this.update(new LambdaUpdateWrapper<H5Project>()
.eq(H5Project::getId, projectId)
.set(H5Project::getStatus, status));
}
@Override
public String getProjectContent(Long projectId) {
if (projectId != null) {
@ -136,4 +161,4 @@ public class H5ProjectServiceImpl extends ServiceImpl<H5ProjectDao, H5Project> i
// 执行分页查询
return baseMapper.selectH5ProjectPage(page, queryDTO);
}
}
}

View File

@ -90,7 +90,7 @@ mybatis-plus:
# 主键类型
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
# 如需改为自增 需要将数据库表全部设置为自增
idType: ASSIGN_ID
idType: AUTO
minioplus:
# rustfs 部署地址
backend: http://localhost:9000