Browse Source

完善专家模块

zyj
sj 2 years ago
parent
commit
822d5e8207
  1. 80
      zsw-bxg/src/main/java/co/yixiang/modules/expert/domain/YxStoreExpert.java
  2. 88
      zsw-bxg/src/main/java/co/yixiang/modules/expert/rest/YxStoreExpertController.java
  3. 49
      zsw-bxg/src/main/java/co/yixiang/modules/expert/service/YxStoreExpertService.java
  4. 54
      zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertDto.java
  5. 19
      zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertQueryCriteria.java
  6. 80
      zsw-bxg/src/main/java/co/yixiang/modules/expert/service/impl/YxStoreExpertServiceImpl.java
  7. 22
      zsw-bxg/src/main/java/co/yixiang/modules/expert/service/mapper/YxStoreExpertMapper.java

80
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));
}
}

88
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<PageResult<YxStoreExpertDto>> 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<Object> create(@Validated @RequestBody YxStoreExpert resources){
return new ResponseEntity<>(yxStoreExpertService.save(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改 专家")
@ApiOperation("修改 专家")
// @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreExpert:edit')")
public ResponseEntity<Object> 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<Object> deleteAll(@RequestBody Long[] ids) {
Arrays.asList(ids).forEach(id->{
yxStoreExpertService.removeById(id);
});
return new ResponseEntity<>(HttpStatus.OK);
}
}

49
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<YxStoreExpert> {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
PageResult<YxStoreExpertDto> queryAll(YxStoreExpertQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<YxStoreExpertDto>
*/
List<YxStoreExpert> queryAll(YxStoreExpertQueryCriteria criteria);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<YxStoreExpertDto> all, HttpServletResponse response) throws IOException;
}

54
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;
}

19
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{
}

80
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<YxStoreExpertMapper, YxStoreExpert> implements YxStoreExpertService {
private final IGenerator generator;
@Override
//@Cacheable
public PageResult<YxStoreExpertDto> queryAll(YxStoreExpertQueryCriteria criteria, Pageable pageable) {
getPage(pageable);
PageInfo<YxStoreExpert> page = new PageInfo<>(queryAll(criteria));
return generator.convertPageInfo(page,YxStoreExpertDto.class);
}
@Override
//@Cacheable
public List<YxStoreExpert> queryAll(YxStoreExpertQueryCriteria criteria){
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreExpert.class, criteria));
}
@Override
public void download(List<YxStoreExpertDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (YxStoreExpertDto yxStoreExpert : all) {
Map<String,Object> 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);
}
}

22
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<YxStoreExpert> {
}
Loading…
Cancel
Save