增加装修接口
This commit is contained in:
parent
04f9d7eb36
commit
6f95683e6f
|
|
@ -0,0 +1,51 @@
|
|||
package com.mdd.admin.controller.decorate;
|
||||
|
||||
import com.mdd.admin.config.aop.Log;
|
||||
import com.mdd.admin.service.decorate.IDecoratePageService;
|
||||
import com.mdd.admin.validate.decorate.DecoratePageParam;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 页面装修管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/decorate/pages")
|
||||
public class PagesController {
|
||||
|
||||
@Resource
|
||||
IDecoratePageService iDecoratePageService;
|
||||
|
||||
/**
|
||||
* 页面装修详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
Map<String, Object> map = iDecoratePageService.detail(id);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面装修保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param decoratePageParam 参数
|
||||
* @return Object
|
||||
*/
|
||||
@Log(title = "页面装修保存")
|
||||
@PostMapping("/save")
|
||||
public Object save(@RequestBody DecoratePageParam decoratePageParam) {
|
||||
iDecoratePageService.save(decoratePageParam);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.mdd.admin.controller.decorate;
|
||||
|
||||
import com.mdd.admin.service.decorate.IDecorateTabbarService;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 装修底部导航管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/decorate/tabbar")
|
||||
public class TabbarController {
|
||||
|
||||
@Resource
|
||||
IDecorateTabbarService iDecorateTabbarService;
|
||||
|
||||
/**
|
||||
* 底部导航详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public Object detail() {
|
||||
List<Map<String, Object>> list = iDecorateTabbarService.detail();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部导航保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
* @return Object
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public Object save(@RequestBody List<Map<String, String>> params) {
|
||||
iDecorateTabbarService.save(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.mdd.admin.service.decorate;
|
||||
|
||||
import com.mdd.admin.validate.decorate.DecoratePageParam;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface IDecoratePageService {
|
||||
|
||||
/**
|
||||
* 页面装修详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> detail(Integer id);
|
||||
|
||||
/**
|
||||
* 页面装修保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param decoratePageParam 参数
|
||||
*/
|
||||
void save(DecoratePageParam decoratePageParam);
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.mdd.admin.service.decorate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 底部导航服务接口类
|
||||
*/
|
||||
public interface IDecorateTabbarService {
|
||||
|
||||
/**
|
||||
* 底部导航详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<Map<String, Object>>
|
||||
*/
|
||||
List<Map<String, Object>> detail();
|
||||
|
||||
/**
|
||||
* 底部导航保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
void save(List<Map<String, String>> params);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.mdd.admin.service.decorate.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.mdd.admin.service.decorate.IDecoratePageService;
|
||||
import com.mdd.admin.validate.decorate.DecoratePageParam;
|
||||
import com.mdd.common.entity.decorate.DecoratePage;
|
||||
import com.mdd.common.mapper.decorate.DecoratePageMapper;
|
||||
import com.mdd.common.utils.ToolsUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class DecoratePageServiceImpl implements IDecoratePageService {
|
||||
|
||||
@Resource
|
||||
DecoratePageMapper decoratePageMapper;
|
||||
|
||||
/**
|
||||
* 页面装修详情
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 主键
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> detail(Integer id) {
|
||||
DecoratePage decoratePage = decoratePageMapper.selectById(id);
|
||||
Assert.notNull(decoratePage, "数据不存在!");
|
||||
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("id", decoratePage.getId());
|
||||
map.put("pageType", decoratePage.getPageType());
|
||||
map.put("pageData", ToolsUtil.jsonToMap(decoratePage.getPageData()));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面装修保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param decoratePageParam 参数
|
||||
*/
|
||||
@Override
|
||||
public void save(DecoratePageParam decoratePageParam) {
|
||||
DecoratePage decoratePage = decoratePageMapper.selectById(decoratePageParam.getId());
|
||||
Assert.notNull(decoratePage, "数据不存在!");
|
||||
|
||||
decoratePage.setPageData(JSON.toJSONString(decoratePageParam.getPageData()));
|
||||
decoratePage.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
decoratePageMapper.updateById(decoratePage);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package com.mdd.admin.service.decorate.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.admin.service.decorate.IDecorateTabbarService;
|
||||
import com.mdd.common.entity.decorate.DecorateTabbar;
|
||||
import com.mdd.common.mapper.decorate.DecorateTabbarMapper;
|
||||
import com.mdd.common.utils.TimeUtil;
|
||||
import com.mdd.common.utils.UrlUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 底部导航服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class DecorateTabbarServiceImpl implements IDecorateTabbarService {
|
||||
|
||||
@Resource
|
||||
DecorateTabbarMapper decorateTabbarMapper;
|
||||
|
||||
/**
|
||||
* 底部导航详情
|
||||
*
|
||||
* @author fzr
|
||||
* @return List<Map<String, Object>>
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> detail() {
|
||||
List<Map<String, Object>> response = new LinkedList<>();
|
||||
List<DecorateTabbar> list = decorateTabbarMapper.selectList(
|
||||
new QueryWrapper<DecorateTabbar>()
|
||||
.orderByAsc("id"));
|
||||
|
||||
for (DecorateTabbar tab: list) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("id", tab.getId());
|
||||
map.put("name", tab.getName());
|
||||
map.put("selected", UrlUtil.toAbsoluteUrl(tab.getSelected()));
|
||||
map.put("unselected", UrlUtil.toAbsoluteUrl(tab.getUnselected()));
|
||||
map.put("link", tab.getLink());
|
||||
map.put("createTime", TimeUtil.timestampToDate(tab.getCreateTime()));
|
||||
map.put("updateTime", TimeUtil.timestampToDate(tab.getUpdateTime()));
|
||||
response.add(map);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部导航保存
|
||||
*
|
||||
* @author fzr
|
||||
* @param params 参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(List<Map<String, String>> params) {
|
||||
decorateTabbarMapper.delete(new QueryWrapper<DecorateTabbar>().gt("id", 0));
|
||||
|
||||
for (Map<String, String> item: params) {
|
||||
DecorateTabbar model = new DecorateTabbar();
|
||||
model.setName(item.get("name"));
|
||||
model.setSelected(UrlUtil.toRelativeUrl(item.get("selected")));
|
||||
model.setUnselected(UrlUtil.toRelativeUrl(item.get("unselected")));
|
||||
model.setLink(item.get("link"));
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
decorateTabbarMapper.insert(model);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ public class ArticleParam implements Serializable {
|
|||
@IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class, change.class})
|
||||
private Integer id;
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0", groups = {create.class, update.class})
|
||||
@IDMust(message = "cid参数必传且需大于0", groups = {create.class, update.class})
|
||||
private Integer cid;
|
||||
|
||||
@NotEmpty(message = "文章标题不能为空", groups = {create.class, update.class})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.mdd.admin.validate.decorate;
|
||||
|
||||
import com.mdd.common.validator.annotation.IDMust;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 页面装修参数类
|
||||
*/
|
||||
@Data
|
||||
public class DecoratePageParam {
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0")
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "pageData参数缺失")
|
||||
private Object pageData;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.mdd.common.entity.decorate;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 页面装修实体
|
||||
*/
|
||||
@Data
|
||||
public class DecoratePage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Integer pageType;
|
||||
private String pageName;
|
||||
private String pageData;
|
||||
private Long createTime;
|
||||
private Long updateTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.mdd.common.entity.decorate;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 底部导航实体
|
||||
*/
|
||||
@Data
|
||||
public class DecorateTabbar implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String selected;
|
||||
private String unselected;
|
||||
private String link;
|
||||
private Long createTime;
|
||||
private Long updateTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.mdd.common.mapper.decorate;
|
||||
|
||||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.decorate.DecoratePage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 页面装修Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface DecoratePageMapper extends IBaseMapper<DecoratePage> {
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.mdd.common.mapper.decorate;
|
||||
|
||||
import com.mdd.common.core.basics.IBaseMapper;
|
||||
import com.mdd.common.entity.decorate.DecorateTabbar;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 底部导航Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface DecorateTabbarMapper extends IBaseMapper<DecorateTabbar> {
|
||||
}
|
||||
Loading…
Reference in New Issue