mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 12:39:05 +08:00
refactor(APP): APP 装修配置优化
This commit is contained in:
1 parent
fcb8003f21
commit
40359afcd1
4 files changed
+147
-65
No files matched your search
+54
@@ -0,0 +1,54 @@
|
||||
package com.pig4cloud.pigx.app.api.enums;
|
||||
|
||||
/**
|
||||
* 页面类型枚举
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2024/12/22
|
||||
*/
|
||||
public enum PageTypeEnums {
|
||||
/**
|
||||
* 首页
|
||||
*/
|
||||
HOME(1, "首页装修"),
|
||||
/**
|
||||
* 个人中心
|
||||
*/
|
||||
USER(2, "个人中心"),
|
||||
/**
|
||||
* 客服设置
|
||||
*/
|
||||
SERVICE(3, "客服设置");
|
||||
|
||||
private final Integer pageType;
|
||||
|
||||
private final String name;
|
||||
|
||||
PageTypeEnums(Integer pageType, String name) {
|
||||
this.pageType = pageType;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按类型获取名称
|
||||
*
|
||||
* @param pageType 页面类型
|
||||
* @return {@link String }
|
||||
*/
|
||||
public static String getNameByType(Integer pageType) {
|
||||
for (PageTypeEnums value : PageTypeEnums.values()) {
|
||||
if (value.pageType.equals(pageType)) {
|
||||
return value.name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Integer getPageType() {
|
||||
return pageType;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
+32
-26
@@ -1,6 +1,5 @@
|
||||
package com.pig4cloud.pigx.app.controller;
|
||||
|
||||
import com.pig4cloud.pigx.app.api.entity.AppPageEntity;
|
||||
import com.pig4cloud.pigx.app.service.AppIndexService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
@@ -14,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* app 首页控制
|
||||
*
|
||||
@@ -29,31 +26,40 @@ import java.util.Map;
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class AppIndexController {
|
||||
|
||||
private final AppIndexService indexService;
|
||||
private final AppIndexService indexService;
|
||||
|
||||
/**
|
||||
* 首页
|
||||
* @return Object
|
||||
*/
|
||||
@Inner(value = false)
|
||||
@GetMapping("/index")
|
||||
public R index() {
|
||||
Map<String, Object> detail = indexService.index();
|
||||
return R.ok(detail);
|
||||
}
|
||||
/**
|
||||
* 获取主页配置
|
||||
*
|
||||
* @return {@link R }
|
||||
*/
|
||||
@Inner(value = false)
|
||||
@GetMapping("/index")
|
||||
public R index() {
|
||||
return R.ok(indexService.index());
|
||||
}
|
||||
|
||||
@Inner(value = false)
|
||||
@GetMapping("/config")
|
||||
public R config() {
|
||||
Map<String, Object> map = indexService.config();
|
||||
return R.ok(map);
|
||||
}
|
||||
/**
|
||||
* 获取移动端appTabbar 配置
|
||||
*
|
||||
* @return {@link R }
|
||||
*/
|
||||
@Inner(value = false)
|
||||
@GetMapping("/config")
|
||||
public R config() {
|
||||
return R.ok(indexService.config());
|
||||
}
|
||||
|
||||
@Inner(value = false)
|
||||
@GetMapping("/decorate")
|
||||
public R decorate(@Validated @RequestParam("id") Integer id) {
|
||||
AppPageEntity detail = indexService.decorate(id);
|
||||
return R.ok(detail);
|
||||
}
|
||||
/**
|
||||
* 根据页面类型查询页面配置
|
||||
*
|
||||
* @param pageType 页面类型
|
||||
* @return {@link R }
|
||||
*/
|
||||
@Inner(value = false)
|
||||
@GetMapping("/decorate")
|
||||
public R decorate(@Validated @RequestParam("id") Integer pageType) {
|
||||
return R.ok(indexService.decorate(pageType));
|
||||
}
|
||||
|
||||
}
|
||||
+17
-1
@@ -1,7 +1,9 @@
|
||||
package com.pig4cloud.pigx.app.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.pig4cloud.pigx.app.api.entity.AppPageEntity;
|
||||
import com.pig4cloud.pigx.app.api.enums.PageTypeEnums;
|
||||
import com.pig4cloud.pigx.app.service.AppPageService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -9,8 +11,12 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 页面管理
|
||||
*
|
||||
@@ -47,8 +53,18 @@ public class AppPageController {
|
||||
*/
|
||||
@Operation(summary = "更新页面", description = "更新页面")
|
||||
@PutMapping
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R update(@RequestBody AppPageEntity page) {
|
||||
return R.ok(pageService.saveOrUpdate(page));
|
||||
List<AppPageEntity> pageEntityList = pageService
|
||||
.list(Wrappers.<AppPageEntity>lambdaQuery().eq(AppPageEntity::getPageType, page.getPageType()));
|
||||
|
||||
if (CollUtil.isNotEmpty(pageEntityList)) {
|
||||
// 删掉原来类型的页面数据
|
||||
pageService.removeByIds(pageEntityList.stream().map(AppPageEntity::getId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
page.setPageName(PageTypeEnums.getNameByType(page.getPageType()));
|
||||
return R.ok(pageService.save(page));
|
||||
}
|
||||
|
||||
}
|
||||
+44
-38
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.pig4cloud.pigx.app.api.entity.AppArticleEntity;
|
||||
import com.pig4cloud.pigx.app.api.entity.AppPageEntity;
|
||||
import com.pig4cloud.pigx.app.api.entity.AppTabbarEntity;
|
||||
import com.pig4cloud.pigx.app.api.enums.PageTypeEnums;
|
||||
import com.pig4cloud.pigx.app.mapper.AppArticleMapper;
|
||||
import com.pig4cloud.pigx.app.mapper.AppPageMapper;
|
||||
import com.pig4cloud.pigx.app.mapper.AppTabbarMapper;
|
||||
@@ -26,48 +27,53 @@ import java.util.Map;
|
||||
@RequiredArgsConstructor
|
||||
public class AppIndexServiceImpl implements AppIndexService {
|
||||
|
||||
private final AppArticleMapper appArticleMapper;
|
||||
private final AppArticleMapper appArticleMapper;
|
||||
|
||||
private final AppTabbarMapper appTabbarMapper;
|
||||
private final AppTabbarMapper appTabbarMapper;
|
||||
|
||||
private final AppPageMapper appPageMapper;
|
||||
private final AppPageMapper appPageMapper;
|
||||
|
||||
/**
|
||||
* 商城首页 首页数据
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> index() {
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
AppPageEntity appPageEntity = appPageMapper.selectById(1);
|
||||
List<AppArticleEntity> articleList = appArticleMapper
|
||||
.selectList(Wrappers.<AppArticleEntity>lambdaQuery().orderByDesc(AppArticleEntity::getSort));
|
||||
response.put("pages", appPageEntity);
|
||||
response.put("article", articleList);
|
||||
return response;
|
||||
}
|
||||
/**
|
||||
* 商城首页 首页数据
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> index() {
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
AppPageEntity appPageEntity = appPageMapper.selectOne(Wrappers.<AppPageEntity>lambdaQuery()
|
||||
.eq(AppPageEntity::getPageType, PageTypeEnums.HOME.getPageType())
|
||||
.orderByDesc(AppPageEntity::getCreateTime),
|
||||
false
|
||||
);
|
||||
List<AppArticleEntity> articleList = appArticleMapper
|
||||
.selectList(Wrappers.<AppArticleEntity>lambdaQuery().orderByDesc(AppArticleEntity::getSort));
|
||||
response.put("pages", appPageEntity);
|
||||
response.put("article", articleList);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> config() {
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
List<AppTabbarEntity> tabbarEntityList = appTabbarMapper.selectList(Wrappers.emptyWrapper());
|
||||
response.put("tabbar", tabbarEntityList);
|
||||
return response;
|
||||
}
|
||||
/**
|
||||
* 导航栏配置
|
||||
*
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> config() {
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
List<AppTabbarEntity> tabbarEntityList = appTabbarMapper.selectList(Wrappers.emptyWrapper());
|
||||
response.put("tabbar", tabbarEntityList);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 装修
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@Override
|
||||
public AppPageEntity decorate(Integer id) {
|
||||
return appPageMapper.selectById(id);
|
||||
}
|
||||
/**
|
||||
* 根据类型查询页面配置
|
||||
*
|
||||
* @param pageType 页面类型
|
||||
* @return {@link AppPageEntity }
|
||||
*/
|
||||
@Override
|
||||
public AppPageEntity decorate(Integer pageType) {
|
||||
return appPageMapper.selectOne(Wrappers.<AppPageEntity>lambdaQuery().eq(AppPageEntity::getPageType, pageType)
|
||||
.orderByDesc(AppPageEntity::getCreateTime), false);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user