From 22ea5f5e036592b2f245d76acb9e938eb5bb83fb Mon Sep 17 00:00:00 2001 From: yujt Date: Thu, 28 May 2020 14:30:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E9=A1=B5=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epdc/controller/StartupController.java | 54 ++++++++ .../controller/StartupPageController.java | 84 ++++++++++++ .../controller/v2/ApiStartupV2Controller.java | 40 ++++++ .../elink/esua/epdc/dao/StartupPageDao.java | 61 +++++++++ .../esua/epdc/entity/StartupPageEntity.java | 63 +++++++++ .../esua/epdc/service/StartupPageService.java | 120 +++++++++++++++++ .../service/impl/StartupPageServiceImpl.java | 124 ++++++++++++++++++ .../main/resources/mapper/StartupPageDao.xml | 26 ++++ 8 files changed, 572 insertions(+) create mode 100644 epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/StartupController.java create mode 100644 epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/StartupPageController.java create mode 100644 epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/v2/ApiStartupV2Controller.java create mode 100644 epdc-cloud-api/src/main/java/com/elink/esua/epdc/dao/StartupPageDao.java create mode 100644 epdc-cloud-api/src/main/java/com/elink/esua/epdc/entity/StartupPageEntity.java create mode 100644 epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/StartupPageService.java create mode 100644 epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/impl/StartupPageServiceImpl.java create mode 100644 epdc-cloud-api/src/main/resources/mapper/StartupPageDao.xml diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/StartupController.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/StartupController.java new file mode 100644 index 0000000..d0abb9f --- /dev/null +++ b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/StartupController.java @@ -0,0 +1,54 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.controller; + +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.result.StartupPageResultDTO; +import com.elink.esua.epdc.service.StartupPageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * 启动页管理 启动页管理 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-03-24 + */ +@RestController +@RequestMapping("startup") +public class StartupController { + + @Autowired + private StartupPageService startupPageService; + + /** + * @Description 获取欢迎页信息 + * @Author songyunpeng + * @Date 2020/3/25 + * @Param [] + * @return com.elink.esua.epdc.commons.tools.utils.Result + **/ + @GetMapping("getStartupPage") + public Result getStartupPage(){ + StartupPageResultDTO data = startupPageService.getStartupPage(); + return new Result().ok(data); + } +} \ No newline at end of file diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/StartupPageController.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/StartupPageController.java new file mode 100644 index 0000000..1eacede --- /dev/null +++ b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/StartupPageController.java @@ -0,0 +1,84 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.controller; + +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.commons.tools.validator.AssertUtils; +import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; +import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; +import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; +import com.elink.esua.epdc.dto.StartupPageDTO; +import com.elink.esua.epdc.service.StartupPageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 启动页管理 启动页管理 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-03-24 + */ +@RestController +@RequestMapping("startuppage") +public class StartupPageController { + + @Autowired + private StartupPageService startupPageService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = startupPageService.listPage(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + StartupPageDTO data = startupPageService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody StartupPageDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + startupPageService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody StartupPageDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + startupPageService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + startupPageService.delete(ids); + return new Result(); + } + +} \ No newline at end of file diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/v2/ApiStartupV2Controller.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/v2/ApiStartupV2Controller.java new file mode 100644 index 0000000..898146d --- /dev/null +++ b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/v2/ApiStartupV2Controller.java @@ -0,0 +1,40 @@ +package com.elink.esua.epdc.controller.v2; + +import com.elink.esua.epdc.commons.api.version.ApiVersion; +import com.elink.esua.epdc.commons.tools.constant.Constant; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.result.StartupPageResultDTO; +import com.elink.esua.epdc.service.StartupPageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author songyunpeng + * @Description 启动页管理 v2 + * @create 2020-05-18 + */ +@ApiVersion(2) +@RestController +@RequestMapping("startup" + Constant.VERSION_CONTROL) +public class ApiStartupV2Controller { + + @Autowired + private StartupPageService startupPageService; + + /** + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @Description 获取欢迎页信息 v2 + * @Author songyunpeng + * @Date 2020/3/25 + * @Param [] + **/ + @GetMapping("getStartupPage") + public Result> getStartupPage() { + List data = startupPageService.getStartupPageV2(); + return new Result>().ok(data); + } +} diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/dao/StartupPageDao.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/dao/StartupPageDao.java new file mode 100644 index 0000000..e749077 --- /dev/null +++ b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/dao/StartupPageDao.java @@ -0,0 +1,61 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.dto.StartupPageDTO; +import com.elink.esua.epdc.dto.result.StartupPageResultDTO; +import com.elink.esua.epdc.entity.StartupPageEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** + * 启动页管理 启动页管理 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-03-24 + */ +@Mapper +public interface StartupPageDao extends BaseDao { + /** + * @Description pc端获取列表 + * @Author songyunpeng + * @Date 2020/3/24 + * @Param [params] + * @return java.util.List + **/ + List selectListOfStartupPageDTO(Map params); + /** + * @Description 获取欢迎页信息 + * @Author songyunpeng + * @Date 2020/3/24 + * @Param [] + * @return com.elink.esua.dto.StartupPageDTO + **/ + StartupPageResultDTO getStartupPage(); + /** + * @Description 获取欢迎页信息 v2 + * @Author songyunpeng + * @Date 2020/3/24 + * @Param [] + * @return com.elink.esua.dto.StartupPageDTO + **/ + List getStartupPageV2(); +} \ No newline at end of file diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/entity/StartupPageEntity.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/entity/StartupPageEntity.java new file mode 100644 index 0000000..4978df9 --- /dev/null +++ b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/entity/StartupPageEntity.java @@ -0,0 +1,63 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 启动页管理 启动页管理 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-03-24 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_startup_page") +public class StartupPageEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + + /** + * 排序 + */ + private Integer sort; + /** + * 图片地址 + */ + private String imgUrl; + + /** + * 停留时长 单位:秒 + */ + private Integer duration; + + /** + * 启用标识 0:否,1:是 + */ + private String enableFlag; + + /** + * 备注 + */ + private String remark; + +} \ No newline at end of file diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/StartupPageService.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/StartupPageService.java new file mode 100644 index 0000000..deb07d0 --- /dev/null +++ b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/StartupPageService.java @@ -0,0 +1,120 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.service; + +import com.elink.esua.epdc.commons.mybatis.service.BaseService; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.dto.StartupPageDTO; +import com.elink.esua.epdc.dto.result.StartupPageResultDTO; +import com.elink.esua.epdc.entity.StartupPageEntity; + +import java.util.List; +import java.util.Map; + +/** + * 启动页管理 启动页管理 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-03-24 + */ +public interface StartupPageService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-24 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-24 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return StartupPageDTO + * @author generator + * @date 2020-03-24 + */ + StartupPageDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-24 + */ + void save(StartupPageDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-24 + */ + void update(StartupPageDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-24 + */ + void delete(String[] ids); + /** + * @Description pcd端查看l列表 + * @Author songyunpeng + * @Date 2020/3/24 + * @Param [params] + * @return com.elink.esua.epdc.commons.tools.page.PageData + **/ + PageData listPage(Map params); + /** + * @Description 获取欢迎页信息 + * @Author songyunpeng + * @Date 2020/3/24 + * @Param [] + * @return com.elink.esua.dto.StartupPageResultDTO + **/ + StartupPageResultDTO getStartupPage(); + /** + * @return com.elink.esua.dto.StartupPageResultDTO + * @Description 获取欢迎页信息 v2 + * @Author songyunpeng + * @Date 2020/3/24 + * @Param [] + **/ + List getStartupPageV2(); +} \ No newline at end of file diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/impl/StartupPageServiceImpl.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/impl/StartupPageServiceImpl.java new file mode 100644 index 0000000..0d44f69 --- /dev/null +++ b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/impl/StartupPageServiceImpl.java @@ -0,0 +1,124 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.tools.constant.FieldConstant; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; +import com.elink.esua.epdc.dao.StartupPageDao; +import com.elink.esua.epdc.dto.StartupPageDTO; +import com.elink.esua.epdc.dto.result.StartupPageResultDTO; +import com.elink.esua.epdc.entity.StartupPageEntity; +import com.elink.esua.epdc.service.StartupPageService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * 启动页管理 启动页管理 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-03-24 + */ +@Service +public class StartupPageServiceImpl extends BaseServiceImpl implements StartupPageService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, StartupPageDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, StartupPageDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public StartupPageDTO get(String id) { + StartupPageEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, StartupPageDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(StartupPageDTO dto) { + StartupPageEntity entity = ConvertUtils.sourceToTarget(dto, StartupPageEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(StartupPageDTO dto) { + StartupPageEntity entity = ConvertUtils.sourceToTarget(dto, StartupPageEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public PageData listPage(Map params) { + IPage page = getPage(params); + List list = baseDao.selectListOfStartupPageDTO(params); + //修改图片 + list.forEach(startupPageDTO -> { + List imgList = Collections.singletonList(startupPageDTO.getImgUrl()); + startupPageDTO.setImgUrlList(imgList); + }); + return new PageData<>(list, page.getTotal()); + } + + @Override + public StartupPageResultDTO getStartupPage() { + return baseDao.getStartupPage(); + } + + @Override + public List getStartupPageV2() { + return baseDao.getStartupPageV2(); + } + +} \ No newline at end of file diff --git a/epdc-cloud-api/src/main/resources/mapper/StartupPageDao.xml b/epdc-cloud-api/src/main/resources/mapper/StartupPageDao.xml new file mode 100644 index 0000000..8818c40 --- /dev/null +++ b/epdc-cloud-api/src/main/resources/mapper/StartupPageDao.xml @@ -0,0 +1,26 @@ + + + + + + + + + + \ No newline at end of file