Commit c3fde926 authored by shiyu's avatar shiyu

图录

parent a46fb2ba
package com.wwdz.ch.admin.controller;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.admin.service.ImageCatelogService;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dto.request.distribution.ImageCatelogRequestDto;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/admin/imageCatelog")
public class ImageCatelogController {
private static final Logger logger = LoggerFactory.getLogger(ImageCatelogController.class);
@Autowired
ImageCatelogService imageCatelogService;
@ApiOperation(value = "查询图录列表")
@PostMapping("/find")
public Result update(@RequestBody ImageCatelogRequestDto dto) {
logger.info("查询图录列表,请求参数:{}", JSON.toJSONString(dto));
return imageCatelogService.findList(dto);
}
}
package com.wwdz.ch.admin.impl;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.admin.service.ImageCatelogService;
import com.wwdz.ch.core.type.PageSearchResult;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.distribution.ImageCatelogDao;
import com.wwdz.ch.db.domain.distribution.ImageCatelog;
import com.wwdz.ch.db.dto.request.distribution.ImageCatelogRequestDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ImageCatelogServiceImpl implements ImageCatelogService {
private static final Logger logger = LoggerFactory.getLogger(ImageCatelogServiceImpl.class);
@Autowired
ImageCatelogDao imageCatelogDao;
@Override
public Result findList(ImageCatelogRequestDto dto) {
try {
List<ImageCatelog> list = imageCatelogDao.findList(dto);
PageInfo pageInfo = new PageInfo(list);
return Result.success(PageSearchResult.of(pageInfo));
} catch (Exception e) {
logger.error("查询图录列表 error:{}", e);
}
return Result.failed();
}
}
package com.wwdz.ch.admin.service;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dto.request.distribution.ImageCatelogRequestDto;
public interface ImageCatelogService {
Result findList(ImageCatelogRequestDto dto);
}
package com.wwdz.ch.admin.impl;
import com.wwdz.ch.core.util.UploadImageCatelogUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class UploadImageCatelogUtilTest {
@Autowired
UploadImageCatelogUtil uploadImageCatelogUtil;
@Test
public void upload() {
uploadImageCatelogUtil.upload();
}
}
\ No newline at end of file
package com.wwdz.ch.core.api; package com.wwdz.ch.core.api;
import com.alibaba.fastjson.JSONArray;
import com.wwdz.ch.core.entity.WxCheckMediaRequestDto; import com.wwdz.ch.core.entity.WxCheckMediaRequestDto;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.OkHttpUtil; import com.wwdz.ch.core.util.OkHttpUtil;
import com.xxdxxs.utils.JsonUtils; import com.xxdxxs.utils.JsonUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -10,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -10,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
@Component @Component
...@@ -36,6 +39,9 @@ public class WxAppletApi { ...@@ -36,6 +39,9 @@ public class WxAppletApi {
private static final String URL_LINK = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=%s"; private static final String URL_LINK = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=%s";
//获取用户访问小程序数据日趋势
private static final String GET_ACCESS_DATA_URL = "https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token=%s";
public String checkMedia(WxCheckMediaRequestDto dto) { public String checkMedia(WxCheckMediaRequestDto dto) {
String accessToken = wxLoginManager.getAccessToken(); String accessToken = wxLoginManager.getAccessToken();
String url = String.format(MEDIA_CHECK_URL, accessToken); String url = String.format(MEDIA_CHECK_URL, accessToken);
...@@ -83,8 +89,42 @@ public class WxAppletApi { ...@@ -83,8 +89,42 @@ public class WxAppletApi {
return urlLink + " "; return urlLink + " ";
} }
/**
* 获取小程序访问数据
* @param startTime
* @param endTime
* @param type
* @return
*/
public Result getAccessData(String startTime, String endTime, int type) {
try {
String accessToken = wxLoginManager.getAccessToken();
String url = String.format(GET_ACCESS_DATA_URL, accessToken);
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
Map<String, Object> map = new HashMap<>();
map.put("begin_date", startTime);
map.put("end_date", endTime);
logger.info("获取加密URLLink 参数:{}", JsonUtils.from(map));
okHttpUtil.addParams(map);
okHttpUtil.post(true);
String responseStr = okHttpUtil.async();
logger.info("获取用户访问小程序数据 response :{}", responseStr);
String listInfo = JsonUtils.getValueByPath(responseStr, "list");
List<Map<String, Object>> dataList = JsonUtils.toMapList(listInfo);
//session_cnt
int sessionCnt = (int) dataList.get(0).get("session_cnt");
//访问次数
int visitPv = (int) dataList.get(0).get("visit_pv");
//访问人数
int visitUv = (int) dataList.get(0).get("visit_uv");
//新用户数
int visitUvNew = (int) dataList.get(0).get("visit_uv_new");
} catch (Exception e) {
logger.error("获取用户访问小程序数据失败:{}", e);
}
return Result.failed();
}
} }
package com.wwdz.ch.core.util;
import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.consts.MediaTypeEnum;
import com.wwdz.ch.core.storage.QiniuStorage;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.distribution.ImageCatelogDao;
import com.wwdz.ch.db.dao.distribution.ImageCatelogDetailDao;
import com.wwdz.ch.db.domain.distribution.ImageCatelog;
import com.wwdz.ch.db.domain.distribution.ImageCatelogDetail;
import com.xxdxxs.utils.CommonUtils;
import jodd.io.findfile.FindFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.InputStream;
import java.util.Date;
import static com.wwdz.ch.core.util.MediaUtil.bufferedImageToInputStream;
@Component
public class UploadImageCatelogUtil {
private static final Logger logger = LoggerFactory.getLogger(UploadImageCatelogUtil.class);
private final static String IMAGE_PATH = "/Users/xxdxxs/Documents/image_catelog/img/";
private final static Integer CATELOG_ID = 1;
@Autowired
ImageCatelogDetailDao imageCatelogDetailDao;
@Autowired
ImageCatelogDao imageCatelogDao;
@Autowired
QiniuStorage qiniuStorage;
public Result upload() {
try {
ImageCatelog imageCatelog = imageCatelogDao.findById(CATELOG_ID);
logger.info("当前上传的图录名称为 : {}" , imageCatelog.getName());
File folder = new File(IMAGE_PATH);
File[] listOfFiles = folder.listFiles();
java.util.Arrays.sort(listOfFiles, new FindFile.FileNameComparator(true));
logger.info("============ 当前目录下共有文件 : {} 个 =============", listOfFiles.length);
int sort = 1;
for (File file : listOfFiles) {
logger.info(">>>>>>>>>> 当前处理的文件名称:{} <<<<<<<<<<", file.getName());
if (isImageFile(file)) {
BufferedImage bufferedImage = ImageIO.read(file);
String keyName = CommConsts.UPLOAD_PRE_DIRECTORY + CommonUtils.getUUID() + "_" + bufferedImage.getWidth() + "x" + bufferedImage.getHeight() + "." + MediaTypeEnum.IMAGE_JPG.getExt();
InputStream imageStream = bufferedImageToInputStream(bufferedImage, MediaTypeEnum.IMAGE_JPG.getExt());
qiniuStorage.store(imageStream, 1, MediaTypeEnum.IMAGE_JPG.getMime(), keyName);
String imageUrl = qiniuStorage.generateUrl(keyName);
ImageCatelogDetail imageCatelogDetail = new ImageCatelogDetail();
imageCatelogDetail.setImgUrl(imageUrl);
imageCatelogDetail.setCatalogId(CATELOG_ID);
imageCatelogDetail.setSort(sort);
imageCatelogDetail.setCreateTime(new Date());
imageCatelogDetailDao.insert(imageCatelogDetail);
sort = sort + 1;
logger.info(">>>>>>>>>> 文件名称:{}, 上传成功 <<<<<<<<<<<<", file.getName());
}
}
logger.info("******************* 文件上传成功 *******************");
} catch (Exception e) {
e.printStackTrace();
logger.error("上传文件出错 :{}", e);
}
return Result.success();
}
public static boolean isImageFile(File file) {
String fileName = file.getName().toLowerCase();
return fileName.endsWith(".png") || fileName.endsWith(".jpg") || fileName.endsWith(".jpeg") || fileName.endsWith(".gif");
}
}
package com.wwdz.ch.db.dao.distribution;
import com.wwdz.ch.db.domain.distribution.ImageCatelog;
import com.wwdz.ch.db.dto.request.distribution.ImageCatelogRequestDto;
import java.util.List;
public interface ImageCatelogDao {
ImageCatelog findById(int id);
List<ImageCatelog> findList(ImageCatelogRequestDto dto);
}
package com.wwdz.ch.db.dao.distribution;
import com.wwdz.ch.db.domain.distribution.ImageCatelogDetail;
public interface ImageCatelogDetailDao {
void insert(ImageCatelogDetail imageCatelogDetail);
}
package com.wwdz.ch.db.domain.distribution;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
* @author shiyu
* @date 2024/05/06
*/
@Data
public class ImageCatelog implements Entity {
/**
* id
*/
private Integer id;
/**
* 标题
*/
private String title;
/**
* 名称
*/
private String name;
/**
* 创建时间
*/
private Date createTime;
/**
* 预览图
*/
private String preview;
/**
* 是否有效
*/
private Boolean isValid;
private static final long serialVersionUID = 1L;
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", title=").append(title);
sb.append(", name=").append(name);
sb.append(", createTime=").append(createTime);
sb.append(", preview=").append(preview);
sb.append(", isValid=").append(isValid);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
ImageCatelog other = (ImageCatelog) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getPreview() == null ? other.getPreview() == null : this.getPreview().equals(other.getPreview()))
&& (this.getIsValid() == null ? other.getIsValid() == null : this.getIsValid().equals(other.getIsValid()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getPreview() == null) ? 0 : getPreview().hashCode());
result = prime * result + ((getIsValid() == null) ? 0 : getIsValid().hashCode());
return result;
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
id("id", "id", "INTEGER", false),
title("title", "title", "VARCHAR", false),
name("name", "name", "VARCHAR", true),
createTime("create_time", "createTime", "TIMESTAMP", false),
preview("preview", "preview", "VARCHAR", false),
isValid("is_valid", "isValid", "BIT", false);
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String BEGINNING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String ENDING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String column;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final boolean isColumnNameDelimited;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String javaProperty;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String jdbcType;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String value() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getValue() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJavaProperty() {
return this.javaProperty;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJdbcType() {
return this.jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
this.isColumnNameDelimited = isColumnNameDelimited;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String desc() {
return this.getEscapedColumnName() + " DESC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String asc() {
return this.getEscapedColumnName() + " ASC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getEscapedColumnName() {
if (this.isColumnNameDelimited) {
return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
} else {
return this.column;
}
}
}
}
\ No newline at end of file
package com.wwdz.ch.db.domain.distribution;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
* @author shiyu
* @date 2024/05/06
*/
@Data
public class ImageCatelogDetail implements Entity {
private Integer id;
/**
* 图片地址
*/
private String imgUrl;
/**
* 顺序
*/
private Integer sort;
/**
* 创建时间
*/
private Date createTime;
/**
* 图录id
*/
private Integer catalogId;
private static final long serialVersionUID = 1L;
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", imgUrl=").append(imgUrl);
sb.append(", sort=").append(sort);
sb.append(", createTime=").append(createTime);
sb.append(", catalogId=").append(catalogId);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
ImageCatelogDetail other = (ImageCatelogDetail) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getImgUrl() == null ? other.getImgUrl() == null : this.getImgUrl().equals(other.getImgUrl()))
&& (this.getSort() == null ? other.getSort() == null : this.getSort().equals(other.getSort()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getCatalogId() == null ? other.getCatalogId() == null : this.getCatalogId().equals(other.getCatalogId()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getImgUrl() == null) ? 0 : getImgUrl().hashCode());
result = prime * result + ((getSort() == null) ? 0 : getSort().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getCatalogId() == null) ? 0 : getCatalogId().hashCode());
return result;
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
id("id", "id", "INTEGER", false),
imgUrl("img_url", "imgUrl", "VARCHAR", false),
sort("sort", "sort", "INTEGER", false),
createTime("create_time", "createTime", "TIMESTAMP", false),
catalogId("catalog_id", "catalogId", "INTEGER", false);
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String BEGINNING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String ENDING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String column;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final boolean isColumnNameDelimited;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String javaProperty;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String jdbcType;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String value() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getValue() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJavaProperty() {
return this.javaProperty;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJdbcType() {
return this.jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
this.isColumnNameDelimited = isColumnNameDelimited;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String desc() {
return this.getEscapedColumnName() + " DESC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String asc() {
return this.getEscapedColumnName() + " ASC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getEscapedColumnName() {
if (this.isColumnNameDelimited) {
return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
} else {
return this.column;
}
}
}
}
\ No newline at end of file
package com.wwdz.ch.db.dto.request.distribution;
import com.wwdz.ch.db.dto.request.BaseRequestDto;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
/**
* @author shiyu
* @date 2024/05/06
*/
@Data
public class ImageCatelogRequestDto extends BaseRequestDto implements Entity {
/**
* id
*/
private Integer id;
/**
* 标题
*/
private String title;
/**
* 名称
*/
private String name;
/**
* 创建时间
*/
private Date createTime;
/**
* 预览图
*/
private String preview;
/**
* 是否有效
*/
private Boolean isValid;
private static final long serialVersionUID = 1L;
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", title=").append(title);
sb.append(", name=").append(name);
sb.append(", createTime=").append(createTime);
sb.append(", preview=").append(preview);
sb.append(", isValid=").append(isValid);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
ImageCatelogRequestDto other = (ImageCatelogRequestDto) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getPreview() == null ? other.getPreview() == null : this.getPreview().equals(other.getPreview()))
&& (this.getIsValid() == null ? other.getIsValid() == null : this.getIsValid().equals(other.getIsValid()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getPreview() == null) ? 0 : getPreview().hashCode());
result = prime * result + ((getIsValid() == null) ? 0 : getIsValid().hashCode());
return result;
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
id("id", "id", "INTEGER", false),
title("title", "title", "VARCHAR", false),
name("name", "name", "VARCHAR", true),
createTime("create_time", "createTime", "TIMESTAMP", false),
preview("preview", "preview", "VARCHAR", false),
isValid("is_valid", "isValid", "BIT", false);
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String BEGINNING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String ENDING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String column;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final boolean isColumnNameDelimited;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String javaProperty;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String jdbcType;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String value() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getValue() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJavaProperty() {
return this.javaProperty;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJdbcType() {
return this.jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
this.isColumnNameDelimited = isColumnNameDelimited;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String desc() {
return this.getEscapedColumnName() + " DESC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String asc() {
return this.getEscapedColumnName() + " ASC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getEscapedColumnName() {
if (this.isColumnNameDelimited) {
return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
} else {
return this.column;
}
}
}
}
\ No newline at end of file
package com.wwdz.ch.db.impl.distribution;
import com.github.pagehelper.PageHelper;
import com.wwdz.ch.db.dao.distribution.ImageCatelogDao;
import com.wwdz.ch.db.domain.distribution.ImageCatelog;
import com.wwdz.ch.db.domain.distribution.ImageCatelogExample;
import com.wwdz.ch.db.dto.request.distribution.ImageCatelogRequestDto;
import com.wwdz.ch.db.mapper.distribution.ImageCatelogMapper;
import com.xxdxxs.db.component.JdbcHelper;
import com.xxdxxs.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class ImageCatelogDaoImpl implements ImageCatelogDao {
@Autowired
ImageCatelogMapper imageCatelogMapper;
@Override
public ImageCatelog findById(int id) {
ImageCatelogExample example = new ImageCatelogExample();
ImageCatelogExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(id);
criteria.andIsValidEqualTo(true);
return imageCatelogMapper.selectByPrimaryKey(id);
}
@Override
public List<ImageCatelog> findList(ImageCatelogRequestDto dto) {
ImageCatelogExample example = new ImageCatelogExample();
ImageCatelogExample.Criteria criteria = example.createCriteria();
if (StringUtils.hasLength(dto.getName())) {
criteria.andNameLike("%" + dto.getName() + "%");
}
if (StringUtils.hasLength(dto.getTitle())) {
criteria.andTitleLike("%" + dto.getTitle() + "%");
}
JdbcHelper.ifPresent(dto.getId(), criteria::andIdEqualTo);
criteria.andIsValidEqualTo(true);
example.setOrderByClause("create_time desc");
PageHelper.startPage(dto.getPage(), dto.getLimit());
return imageCatelogMapper.selectByExample(example);
}
}
package com.wwdz.ch.db.impl.distribution;
import com.wwdz.ch.db.dao.distribution.ImageCatelogDetailDao;
import com.wwdz.ch.db.domain.distribution.ImageCatelogDetail;
import com.wwdz.ch.db.mapper.distribution.ImageCatelogDetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
public class ImageCatelogDetailDaoImpl implements ImageCatelogDetailDao {
@Autowired
ImageCatelogDetailMapper imageCatelogDetailMapper;
@Override
public void insert(ImageCatelogDetail imageCatelogDetail) {
imageCatelogDetailMapper.insert(imageCatelogDetail);
}
}
package com.wwdz.ch.db.mapper.distribution;
import com.wwdz.ch.db.domain.distribution.ImageCatelogDetail;
import com.wwdz.ch.db.domain.distribution.ImageCatelogDetailExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface ImageCatelogDetailMapper {
long countByExample(ImageCatelogDetailExample example);
int deleteByExample(ImageCatelogDetailExample example);
int deleteByPrimaryKey(Integer id);
int insert(ImageCatelogDetail record);
int insertSelective(ImageCatelogDetail record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
ImageCatelogDetail selectOneByExample(ImageCatelogDetailExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
ImageCatelogDetail selectOneByExampleSelective(@Param("example") ImageCatelogDetailExample example, @Param("selective") ImageCatelogDetail.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<ImageCatelogDetail> selectByExampleSelective(@Param("example") ImageCatelogDetailExample example, @Param("selective") ImageCatelogDetail.Column ... selective);
List<ImageCatelogDetail> selectByExample(ImageCatelogDetailExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog_detail
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
ImageCatelogDetail selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") ImageCatelogDetail.Column ... selective);
ImageCatelogDetail selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") ImageCatelogDetail record, @Param("example") ImageCatelogDetailExample example);
int updateByExample(@Param("record") ImageCatelogDetail record, @Param("example") ImageCatelogDetailExample example);
int updateByPrimaryKeySelective(ImageCatelogDetail record);
int updateByPrimaryKey(ImageCatelogDetail record);
}
\ No newline at end of file
package com.wwdz.ch.db.mapper.distribution;
import com.wwdz.ch.db.domain.distribution.ImageCatelog;
import com.wwdz.ch.db.domain.distribution.ImageCatelogExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface ImageCatelogMapper {
long countByExample(ImageCatelogExample example);
int deleteByExample(ImageCatelogExample example);
int deleteByPrimaryKey(Integer id);
int insert(ImageCatelog record);
int insertSelective(ImageCatelog record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
ImageCatelog selectOneByExample(ImageCatelogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
ImageCatelog selectOneByExampleSelective(@Param("example") ImageCatelogExample example, @Param("selective") ImageCatelog.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<ImageCatelog> selectByExampleSelective(@Param("example") ImageCatelogExample example, @Param("selective") ImageCatelog.Column ... selective);
List<ImageCatelog> selectByExample(ImageCatelogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table image_catelog
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
ImageCatelog selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") ImageCatelog.Column ... selective);
ImageCatelog selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") ImageCatelog record, @Param("example") ImageCatelogExample example);
int updateByExample(@Param("record") ImageCatelog record, @Param("example") ImageCatelogExample example);
int updateByPrimaryKeySelective(ImageCatelog record);
int updateByPrimaryKey(ImageCatelog record);
}
\ No newline at end of file
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution" <javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution"
targetProject="ch-dao/src/main/java"/> targetProject="ch-dao/src/main/java"/>
<table tableName="supplier_item" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"> <table tableName="image_catelog" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" /> <generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table> </table>
......
...@@ -4,10 +4,7 @@ import com.github.pagehelper.PageInfo; ...@@ -4,10 +4,7 @@ import com.github.pagehelper.PageInfo;
import com.wechat.pay.java.service.refund.model.Refund; import com.wechat.pay.java.service.refund.model.Refund;
import com.wechat.pay.java.service.refund.model.Status; import com.wechat.pay.java.service.refund.model.Status;
import com.wwdz.ch.core.api.wxpay.WxPayServiceApi; import com.wwdz.ch.core.api.wxpay.WxPayServiceApi;
import com.wwdz.ch.core.consts.CommConsts; import com.wwdz.ch.core.consts.*;
import com.wwdz.ch.core.consts.DistributionEnum;
import com.wwdz.ch.core.consts.LogisticsEnum;
import com.wwdz.ch.core.consts.ResultCode;
import com.wwdz.ch.core.entity.wxPay.DistributionOrderRefundRequestDto; import com.wwdz.ch.core.entity.wxPay.DistributionOrderRefundRequestDto;
import com.wwdz.ch.core.notify.AliSmsSender; import com.wwdz.ch.core.notify.AliSmsSender;
import com.wwdz.ch.core.type.PageSearchResult; import com.wwdz.ch.core.type.PageSearchResult;
...@@ -1134,7 +1131,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { ...@@ -1134,7 +1131,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
refundOrder.setDistributorId(distributionOrder.getSellerId()); refundOrder.setDistributorId(distributionOrder.getSellerId());
refundOrder.setCreateTime(now); refundOrder.setCreateTime(now);
refundOrder.setUpdateTime(now); refundOrder.setUpdateTime(now);
refundOrder.setState(DistributionEnum.RefundOrderStateEnum.PROCESSING.getCode()); refundOrder.setState(RefundOrderEnum.StateEnum.PROCESSING.getCode());
refundOrderDao.insert(refundOrder); refundOrderDao.insert(refundOrder);
//退款受理成功,订单的状态改为退款受理中 //退款受理成功,订单的状态改为退款受理中
distributionOrderDao.updateState(distributionOrderId, DistributionEnum.DistributionOrderStateEnum.REFUNDING.getCode()); distributionOrderDao.updateState(distributionOrderId, DistributionEnum.DistributionOrderStateEnum.REFUNDING.getCode());
......
...@@ -89,7 +89,7 @@ public class WxPayServiceTest { ...@@ -89,7 +89,7 @@ public class WxPayServiceTest {
@Test @Test
public void refund() { public void refund() {
List<String> list = Arrays.asList("DA2404231044297455211"); List<String> list = Arrays.asList("DA2404301433196070258");
list.forEach(orderId ->{ list.forEach(orderId ->{
DistributionOrderRequestDto dto = new DistributionOrderRequestDto(); DistributionOrderRequestDto dto = new DistributionOrderRequestDto();
dto.setDistributionOrderId(orderId); dto.setDistributionOrderId(orderId);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment