From a29c075eb3461703b49f604196ad159bb80d3ac1 Mon Sep 17 00:00:00 2001 From: Jackwang Date: Tue, 11 Jan 2022 09:48:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EpidemicUserSyncController.java | 94 ++++++++++++++++ .../epidemic/dao/EpidemicUserSyncDao.java | 33 ++++++ .../entity/EpidemicUserSyncEntity.java | 45 ++++++++ .../epidemic/excel/EpidemicUserSyncExcel.java | 41 +++++++ .../service/EpidemicUserSyncService.java | 96 +++++++++++++++++ .../impl/EpidemicUserSyncServiceImpl.java | 100 ++++++++++++++++++ .../mapper/epimedic/EpidemicUserSyncDao.xml | 12 +++ 7 files changed, 421 insertions(+) create mode 100644 epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/controller/EpidemicUserSyncController.java create mode 100644 epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/dao/EpidemicUserSyncDao.java create mode 100644 epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/entity/EpidemicUserSyncEntity.java create mode 100644 epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/excel/EpidemicUserSyncExcel.java create mode 100644 epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/service/EpidemicUserSyncService.java create mode 100644 epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/service/impl/EpidemicUserSyncServiceImpl.java create mode 100644 epdc-cloud-analysis-pc/src/main/resources/mapper/epimedic/EpidemicUserSyncDao.xml diff --git a/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/controller/EpidemicUserSyncController.java b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/controller/EpidemicUserSyncController.java new file mode 100644 index 0000000..b384e00 --- /dev/null +++ b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/controller/EpidemicUserSyncController.java @@ -0,0 +1,94 @@ +/** + * 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.modules.epidemic.controller; + +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; +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.analysis.pc.epidemic.EpidemicUserSyncDTO; +import com.elink.esua.epdc.modules.epidemic.excel.EpidemicUserSyncExcel; +import com.elink.esua.epdc.modules.epidemic.service.EpidemicUserSyncService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2022-01-11 + */ +@RestController +@RequestMapping("epidemicusersync") +public class EpidemicUserSyncController { + + @Autowired + private EpidemicUserSyncService epidemicUserSyncService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = epidemicUserSyncService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + EpidemicUserSyncDTO data = epidemicUserSyncService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody EpidemicUserSyncDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + epidemicUserSyncService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody EpidemicUserSyncDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + epidemicUserSyncService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + epidemicUserSyncService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = epidemicUserSyncService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, EpidemicUserSyncExcel.class); + } + +} diff --git a/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/dao/EpidemicUserSyncDao.java b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/dao/EpidemicUserSyncDao.java new file mode 100644 index 0000000..1195a3c --- /dev/null +++ b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/dao/EpidemicUserSyncDao.java @@ -0,0 +1,33 @@ +/** + * 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.modules.epidemic.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.modules.epidemic.entity.EpidemicUserSyncEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2022-01-11 + */ +@Mapper +public interface EpidemicUserSyncDao extends BaseDao { + +} diff --git a/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/entity/EpidemicUserSyncEntity.java b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/entity/EpidemicUserSyncEntity.java new file mode 100644 index 0000000..9d16723 --- /dev/null +++ b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/entity/EpidemicUserSyncEntity.java @@ -0,0 +1,45 @@ +/** + * 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.modules.epidemic.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2022-01-11 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epidemic_user_sync") +public class EpidemicUserSyncEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 同步时间 + */ + private Date syncDate; + +} diff --git a/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/excel/EpidemicUserSyncExcel.java b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/excel/EpidemicUserSyncExcel.java new file mode 100644 index 0000000..0df49a7 --- /dev/null +++ b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/excel/EpidemicUserSyncExcel.java @@ -0,0 +1,41 @@ +/** + * 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.modules.epidemic.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2022-01-11 + */ +@Data +public class EpidemicUserSyncExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "同步时间") + private Date syncDate; + + +} diff --git a/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/service/EpidemicUserSyncService.java b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/service/EpidemicUserSyncService.java new file mode 100644 index 0000000..2ce51be --- /dev/null +++ b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/service/EpidemicUserSyncService.java @@ -0,0 +1,96 @@ +/** + * 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.modules.epidemic.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.analysis.pc.epidemic.EpidemicUserSyncDTO; +import com.elink.esua.epdc.modules.epidemic.entity.EpidemicUserSyncEntity; + +import java.util.List; +import java.util.Map; + +/** + * + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2022-01-11 + */ +public interface EpidemicUserSyncService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2022-01-11 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2022-01-11 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return EpidemicUserSyncDTO + * @author generator + * @date 2022-01-11 + */ + EpidemicUserSyncDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2022-01-11 + */ + void save(EpidemicUserSyncDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2022-01-11 + */ + void update(EpidemicUserSyncDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2022-01-11 + */ + void delete(String[] ids); +} diff --git a/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/service/impl/EpidemicUserSyncServiceImpl.java b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/service/impl/EpidemicUserSyncServiceImpl.java new file mode 100644 index 0000000..c80f2d9 --- /dev/null +++ b/epdc-cloud-analysis-pc/src/main/java/com/elink/esua/epdc/modules/epidemic/service/impl/EpidemicUserSyncServiceImpl.java @@ -0,0 +1,100 @@ +/** + * 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.modules.epidemic.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.dto.analysis.pc.epidemic.EpidemicUserSyncDTO; +import com.elink.esua.epdc.modules.epidemic.dao.EpidemicUserSyncDao; +import com.elink.esua.epdc.modules.epidemic.entity.EpidemicUserSyncEntity; +import com.elink.esua.epdc.modules.epidemic.service.EpidemicUserSyncService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2022-01-11 + */ +@Service +public class EpidemicUserSyncServiceImpl extends BaseServiceImpl implements EpidemicUserSyncService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, EpidemicUserSyncDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, EpidemicUserSyncDTO.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 EpidemicUserSyncDTO get(String id) { + EpidemicUserSyncEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, EpidemicUserSyncDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(EpidemicUserSyncDTO dto) { + EpidemicUserSyncEntity entity = ConvertUtils.sourceToTarget(dto, EpidemicUserSyncEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(EpidemicUserSyncDTO dto) { + EpidemicUserSyncEntity entity = ConvertUtils.sourceToTarget(dto, EpidemicUserSyncEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} diff --git a/epdc-cloud-analysis-pc/src/main/resources/mapper/epimedic/EpidemicUserSyncDao.xml b/epdc-cloud-analysis-pc/src/main/resources/mapper/epimedic/EpidemicUserSyncDao.xml new file mode 100644 index 0000000..7cbbaf7 --- /dev/null +++ b/epdc-cloud-analysis-pc/src/main/resources/mapper/epimedic/EpidemicUserSyncDao.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + +