package com.dwarfeng.familyhelper.webapi.node.controller.v1.life;
import com.dwarfeng.familyhelper.life.sdk.bean.dto.WebInputActivityDataNodeCreateInfo;
import com.dwarfeng.familyhelper.life.sdk.bean.dto.WebInputActivityDataNodeUpdateInfo;
import com.dwarfeng.familyhelper.life.sdk.bean.entity.JSFixedFastJsonActivityDataNode;
import com.dwarfeng.familyhelper.life.stack.bean.entity.ActivityDataNode;
import com.dwarfeng.familyhelper.webapi.sdk.bean.disp.life.JSFixedFastJsonDispActivityDataNode;
import com.dwarfeng.familyhelper.webapi.stack.bean.disp.life.DispActivityDataNode;
import com.dwarfeng.familyhelper.webapi.stack.handler.system.TokenHandler;
import com.dwarfeng.familyhelper.webapi.stack.service.life.ActivityDataNodeResponseService;
import com.dwarfeng.subgrade.sdk.bean.dto.FastJsonResponseData;
import com.dwarfeng.subgrade.sdk.bean.dto.JSFixedFastJsonPagedData;
import com.dwarfeng.subgrade.sdk.bean.dto.PagingUtil;
import com.dwarfeng.subgrade.sdk.bean.dto.ResponseDataUtil;
import com.dwarfeng.subgrade.sdk.bean.key.JSFixedFastJsonLongIdKey;
import com.dwarfeng.subgrade.sdk.bean.key.WebInputLongIdKey;
import com.dwarfeng.subgrade.sdk.interceptor.analyse.BehaviorAnalyse;
import com.dwarfeng.subgrade.sdk.interceptor.analyse.SkipRecord;
import com.dwarfeng.subgrade.sdk.interceptor.http.BindingCheck;
import com.dwarfeng.subgrade.sdk.interceptor.login.LoginRequired;
import com.dwarfeng.subgrade.stack.bean.BeanTransformer;
import com.dwarfeng.subgrade.stack.bean.dto.PagedData;
import com.dwarfeng.subgrade.stack.bean.dto.PagingInfo;
import com.dwarfeng.subgrade.stack.bean.key.LongIdKey;
import com.dwarfeng.subgrade.stack.bean.key.StringIdKey;
import com.dwarfeng.subgrade.stack.exception.ServiceExceptionMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/**
* 活动数据节点控制器。
*
* @author DwArFeng
* @since 1.0.10
*/
@RestController
@RequestMapping("/api/v1/life")
public class ActivityDataNodeController {
private static final Logger LOGGER = LoggerFactory.getLogger(ActivityDataNodeController.class);
private final ActivityDataNodeResponseService service;
private final ServiceExceptionMapper sem;
private final BeanTransformer<ActivityDataNode, JSFixedFastJsonActivityDataNode>
activityDataNodeBeanTransformer;
private final BeanTransformer<DispActivityDataNode, JSFixedFastJsonDispActivityDataNode>
dispActivityDataNodeBeanTransformer;
private final TokenHandler tokenHandler;
public ActivityDataNodeController(
ActivityDataNodeResponseService service, ServiceExceptionMapper sem,
BeanTransformer<ActivityDataNode, JSFixedFastJsonActivityDataNode> activityDataNodeBeanTransformer,
BeanTransformer<DispActivityDataNode, JSFixedFastJsonDispActivityDataNode>
dispActivityDataNodeBeanTransformer,
TokenHandler tokenHandler
) {
this.service = service;
this.sem = sem;
this.activityDataNodeBeanTransformer = activityDataNodeBeanTransformer;
this.dispActivityDataNodeBeanTransformer = dispActivityDataNodeBeanTransformer;
this.tokenHandler = tokenHandler;
}
@GetMapping("/activity-data-node/{id}/exists")
@BehaviorAnalyse
@LoginRequired
public FastJsonResponseData<Boolean> exists(HttpServletRequest request, @PathVariable("id") Long id) {
try {
boolean exists = service.exists(new LongIdKey(id));
return FastJsonResponseData.of(ResponseDataUtil.good(exists));
} catch (Exception e) {
LOGGER.warn("Controller 异常, 信息如下: ", e);
return FastJsonResponseData.of(ResponseDataUtil.bad(e, sem));
}
}
@GetMapping("/activity-data-node/{id}")
@BehaviorAnalyse
@LoginRequired
public FastJsonResponseData<JSFixedFastJsonActivityDataNode> get(
HttpServletRequest request, @PathVariable("id") Long id
) {
try {
ActivityDataNode activityDataNode = service.get(new LongIdKey(id));
return FastJsonResponseData.of(ResponseDataUtil.good(JSFixedFastJsonActivityDataNode.of(activityDataNode)));
} catch (Exception e) {
LOGGER.warn("Controller 异常, 信息如下: ", e);
return FastJsonResponseData.of(ResponseDataUtil.bad(e, sem));
}
}
@GetMapping("/activity-data-node/all")
@BehaviorAnalyse
@SkipRecord
@LoginRequired
public FastJsonResponseData<JSFixedFastJsonPagedData<JSFixedFastJsonActivityDataNode>> all(
HttpServletRequest request, @RequestParam("page") int page, @RequestParam("rows") int rows) {
try {
PagedData<ActivityDataNode> all = service.all(new PagingInfo(page, rows));
PagedData<JSFixedFastJsonActivityDataNode> transform = PagingUtil.transform(
all, activityDataNodeBeanTransformer
);
return FastJsonResponseData.of(ResponseDataUtil.good(JSFixedFastJsonPagedData.of(transform)));
} catch (Exception e) {
LOGGER.warn("Controller 异常, 信息如下: ", e);
return FastJsonResponseData.of(ResponseDataUtil.bad(e, sem));
}
}
@GetMapping(value = {
"/activity-data-set/{activityDataSetId}/activity-data-node", "/activity-data-set//activity-data-node"
})
@BehaviorAnalyse
@SkipRecord
@LoginRequired
public FastJsonResponseData<JSFixedFastJsonPagedData<JSFixedFastJsonActivityDataNode>> childForActivityDataSet(
@PathVariable(required = false, value = "activityDataSetId") Long activityDataSetId,
@RequestParam("page") int page, @RequestParam("rows") int rows
) {
try {
LongIdKey activityDataSetKey = null;
if (Objects.nonNull(activityDataSetId)) {
activityDataSetKey = new LongIdKey(activityDataSetId);
}
PagedData<ActivityDataNode> childForActivityDataSet = service.childForActivityDataSet(
activityDataSetKey, new PagingInfo(page, rows));
PagedData<JSFixedFastJsonActivityDataNode> transform = PagingUtil.transform(
childForActivityDataSet, activityDataNodeBeanTransformer);
return FastJsonResponseData.of(ResponseDataUtil.good(JSFixedFastJsonPagedData.of(transform)));
} catch (Exception e) {
LOGGER.warn("Controller 异常, 信息如下: ", e);
return FastJsonResponseData.of(ResponseDataUtil.bad(e, sem));
}
}
@GetMapping("/activity-data-set/{activityDataSetId}/activity-data-node/root")
@BehaviorAnalyse
@SkipRecord
@LoginRequired
public FastJsonResponseData<JSFixedFastJsonPagedData<JSFixedFastJsonActivityDataNode>> childForActivityDataSetRoot(
HttpServletRequest request,
@PathVariable("activityDataSetId") long activityDataSetId,
@RequestParam("page") int page, @RequestParam("rows") int rows
) {
try {
PagedData<ActivityDataNode> childForActivityDataSetRoot = service.childForActivityDataSetRoot(
new LongIdKey(activityDataSetId), new PagingInfo(page, rows)
);
PagedData<JSFixedFastJsonActivityDataNode> transform = PagingUtil.transform(
childForActivityDataSetRoot, activityDataNodeBeanTransformer
);
return FastJsonResponseData.of(ResponseDataUtil.good(JSFixedFastJsonPagedData.of(transform)));
} catch (Exception e) {
LOGGER.warn("Controller 异常, 信息如下: ", e);
return FastJsonResponseData.of(ResponseDataUtil.bad(e, sem));
}
}
@GetMapping("/activity-data-node/{parentId}/child")
@Beh
沐知全栈开发
- 粉丝: 5819
- 资源: 5218
最新资源
- kde-l10n-Bosnian-4.10.5-2.el7.x64-86.rpm.tar.gz
- kde-l10n-Brazil-4.10.5-2.el7.x64-86.rpm.tar.gz
- 纯电动汽车Matlab Simulink仿真模型:动力性与经济性模拟,模块化设计方便升级与使用,纯电动汽车Matlab Simulink软件模型,纯电动汽车动力性、经济性仿真模型 1.本模型基于Mat
- kde-l10n-British-4.10.5-2.el7.x64-86.rpm.tar.gz
- 基于ID=0控制的电机模型参考自适应RLS参数辨识方法的有效性仿真研究,该模型基于id=0控制 ,通过电机的基本数学模型,采用模型参考自适应法对其RLS参数辨识,仿真结果表明了该方法的有效性 ,关键词
- kde-l10n-Bulgarian-4.10.5-2.el7.x64-86.rpm.tar.gz
- axmol-cocos资源
- 直驱式永磁同步风力发电系统仿真模型研究与分析,直驱式永磁同步风力发电系统的仿真模型 ,核心关键词:直驱式永磁同步风力发电系统; 仿真模型; 直驱式; 永磁同步; 风力发电 ,"仿真模型研究:直驱式永磁
- kde-l10n-Catalan-4.10.5-2.el7.x64-86.rpm.tar.gz
- 基于有向图的时变多智能体系统MASs分组编队控制与Matlab脚本数值仿真实验研究,有向图,时变多智能体系统 MASs,分布式自适应跟踪,分组编队控制,Matlab脚本,Matlab脚本数值仿真实验
- kde-l10n-Catalan-Valencian-4.10.5-2.el7.x64-86.rpm.tar.gz
- iRTU-硬件开发资源
- test-c-蓝桥杯资源
- kde-l10n-Chinese-4.10.5-2.el7.x64-86.rpm.tar.gz
- 默纳克全系列刷机大全:协议修改、软件烧录,涵盖主板、轿顶板与外呼板等一站式解决方案,默纳克刷机,默纳克刷协议,默纳克显示板 外呼板协议更改 烧录 默纳克各种软件各种刷机,含主板、轿顶板、外呼板刷机软件
- 基于Java Swing +SQL Server实现的网吧计费管理系统毕业论文
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈