From 822d5e8207674f985110a320b9026383379b1c64 Mon Sep 17 00:00:00 2001 From: sj <1304317391@qq.com> Date: Mon, 19 Sep 2022 16:58:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=B8=93=E5=AE=B6=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/expert/domain/YxStoreExpert.java | 80 +++++++++++++++++ .../expert/rest/YxStoreExpertController.java | 88 +++++++++++++++++++ .../expert/service/YxStoreExpertService.java | 49 +++++++++++ .../expert/service/dto/YxStoreExpertDto.java | 54 ++++++++++++ .../dto/YxStoreExpertQueryCriteria.java | 19 ++++ .../impl/YxStoreExpertServiceImpl.java | 80 +++++++++++++++++ .../service/mapper/YxStoreExpertMapper.java | 22 +++++ 7 files changed, 392 insertions(+) create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/expert/domain/YxStoreExpert.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/expert/rest/YxStoreExpertController.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/expert/service/YxStoreExpertService.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertDto.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertQueryCriteria.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/expert/service/impl/YxStoreExpertServiceImpl.java create mode 100644 zsw-bxg/src/main/java/co/yixiang/modules/expert/service/mapper/YxStoreExpertMapper.java diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/expert/domain/YxStoreExpert.java b/zsw-bxg/src/main/java/co/yixiang/modules/expert/domain/YxStoreExpert.java new file mode 100644 index 00000000..85691552 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/expert/domain/YxStoreExpert.java @@ -0,0 +1,80 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.expert.domain; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.validation.constraints.*; +import java.sql.Timestamp; +import java.io.Serializable; + +/** +* @author hupeng +* @date 2022-09-17 +*/ +@Data +@TableName("yx_store_expert") +public class YxStoreExpert implements Serializable { + + /** 专家id */ + @TableId + private Long id; + + + /** 商户Id(0为总后台管理员创建,不为0的时候是商户后台创建) */ + private Integer merId; + + + /** 专家人像大图 */ + @NotBlank + private String image; + + + /** 专家名称 */ + @NotBlank + private String expertName; + + + /** 专家简介 */ + @NotBlank + private String expertInfo; + + + /** 专家的职级 */ + @NotBlank + private String expertStatus; + + + /** 专家所属单位 */ + @NotBlank + private String expertUnit; + + + /** 添加时间 */ + @TableField(fill= FieldFill.INSERT) + private Timestamp createTime; + + + /** 更新时间 */ + @TableField(fill= FieldFill.INSERT_UPDATE) + private Timestamp updateTime; + + + /** 是否删除 */ + private Integer isDel; + + + public void copy(YxStoreExpert source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/expert/rest/YxStoreExpertController.java b/zsw-bxg/src/main/java/co/yixiang/modules/expert/rest/YxStoreExpertController.java new file mode 100644 index 00000000..6ce711ed --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/expert/rest/YxStoreExpertController.java @@ -0,0 +1,88 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.expert.rest; + +import co.yixiang.domain.PageResult; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.expert.domain.YxStoreExpert; +import co.yixiang.modules.expert.service.YxStoreExpertService; +import co.yixiang.modules.expert.service.dto.YxStoreExpertDto; +import co.yixiang.modules.expert.service.dto.YxStoreExpertQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Arrays; +/** +* @author hupeng +* @date 2022-09-17 +*/ +@AllArgsConstructor +@Api(tags = " ss管理") +@RestController +@RequestMapping("/api/yxStoreExpert") +public class YxStoreExpertController { + + private final YxStoreExpertService yxStoreExpertService; + private final IGenerator generator; + + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") +// @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreExpert:list')") + public void download(HttpServletResponse response, YxStoreExpertQueryCriteria criteria) throws IOException { + yxStoreExpertService.download(generator.convert(yxStoreExpertService.queryAll(criteria), YxStoreExpertDto.class), response); + } + + @GetMapping + @Log("查询 专家") + @ApiOperation("查询 专家") +// @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreExpert:list')") + public ResponseEntity> getYxStoreExperts(YxStoreExpertQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStoreExpertService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增 专家") + @ApiOperation("新增 专家") +// @PreAuthorize("ss.hasAnyPermissions('admin','yxStoreExpert:add')") + public ResponseEntity create(@Validated @RequestBody YxStoreExpert resources){ + return new ResponseEntity<>(yxStoreExpertService.save(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改 专家") + @ApiOperation("修改 专家") +// @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreExpert:edit')") + public ResponseEntity update(@Validated @RequestBody YxStoreExpert resources){ + yxStoreExpertService.updateById(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除 专家") + @ApiOperation("删除 专家") +// @PreAuthorize("@ss.hasAnyPermissions ('admin','yxStoreExpert:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Long[] ids) { + Arrays.asList(ids).forEach(id->{ + yxStoreExpertService.removeById(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/YxStoreExpertService.java b/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/YxStoreExpertService.java new file mode 100644 index 00000000..5f9bb465 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/YxStoreExpertService.java @@ -0,0 +1,49 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.expert.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.domain.PageResult; +import co.yixiang.modules.expert.domain.YxStoreExpert; +import co.yixiang.modules.expert.service.dto.YxStoreExpertDto; +import co.yixiang.modules.expert.service.dto.YxStoreExpertQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +/** +* @author hupeng +* @date 2022-09-17 +*/ +public interface YxStoreExpertService extends BaseService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + PageResult queryAll(YxStoreExpertQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreExpertQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertDto.java new file mode 100644 index 00000000..247e10bb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertDto.java @@ -0,0 +1,54 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.expert.service.dto; + +import lombok.Data; +import lombok.Value; + +import java.sql.Timestamp; +import java.io.Serializable; + +/** +* @author hupeng +* @date 2022-09-17 +*/ +@Data +public class YxStoreExpertDto implements Serializable { + + /** 专家id */ + private Long id; + + /** 商户Id(0为总后台管理员创建,不为0的时候是商户后台创建) */ + + private Integer merId; + + /** 专家人像大图 */ + private String image; + + /** 专家名称 */ + private String expertName; + + /** 专家简介 */ + private String expertInfo; + + /** 专家的职级 */ + private String expertStatus; + + /** 专家所属单位 */ + private String expertUnit; + + /** 添加时间 */ + private Timestamp createTime; + + /** 更新时间 */ + private Timestamp updateTime; + + /** 是否删除 */ + private Integer isDel; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertQueryCriteria.java new file mode 100644 index 00000000..3f3e2d64 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertQueryCriteria.java @@ -0,0 +1,19 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.expert.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2022-09-17 +*/ +@Data +public class YxStoreExpertQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/impl/YxStoreExpertServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/impl/YxStoreExpertServiceImpl.java new file mode 100644 index 00000000..a13baca4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/impl/YxStoreExpertServiceImpl.java @@ -0,0 +1,80 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.expert.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.domain.PageResult; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.expert.domain.YxStoreExpert; +import co.yixiang.modules.expert.service.YxStoreExpertService; +import co.yixiang.modules.expert.service.dto.YxStoreExpertDto; +import co.yixiang.modules.expert.service.dto.YxStoreExpertQueryCriteria; +import co.yixiang.modules.expert.service.mapper.YxStoreExpertMapper; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +/** +* @author hupeng +* @date 2022-09-17 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "yxStoreExpert") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreExpertServiceImpl extends BaseServiceImpl implements YxStoreExpertService { + + private final IGenerator generator; + + @Override + //@Cacheable + public PageResult queryAll(YxStoreExpertQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + return generator.convertPageInfo(page,YxStoreExpertDto.class); + } + + + @Override + //@Cacheable + public List queryAll(YxStoreExpertQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreExpert.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreExpertDto yxStoreExpert : all) { + Map map = new LinkedHashMap<>(); + map.put("商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)", yxStoreExpert.getMerId()); + map.put("专家人像大图", yxStoreExpert.getImage()); + map.put("专家名称", yxStoreExpert.getExpertName()); + map.put("专家简介", yxStoreExpert.getExpertInfo()); + map.put("专家的职级", yxStoreExpert.getExpertStatus()); + map.put("专家所属单位", yxStoreExpert.getExpertUnit()); + map.put("添加时间", yxStoreExpert.getCreateTime()); + map.put("更新时间", yxStoreExpert.getUpdateTime()); + map.put("是否删除", yxStoreExpert.getIsDel()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/mapper/YxStoreExpertMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/mapper/YxStoreExpertMapper.java new file mode 100644 index 00000000..b2aef19c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/expert/service/mapper/YxStoreExpertMapper.java @@ -0,0 +1,22 @@ +/** +* Copyright (C) 2018-2020 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.expert.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.expert.domain.YxStoreExpert; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2022-09-17 +*/ +@Repository +public interface YxStoreExpertMapper extends CoreMapper { + +}