Commit a0514228 authored by shiyu's avatar shiyu

钱币设置

parent 289005df
...@@ -64,8 +64,8 @@ public class AdminGoodsController { ...@@ -64,8 +64,8 @@ public class AdminGoodsController {
@GetMapping("/list") @GetMapping("/list")
public Object list(String name, @RequestParam(defaultValue = "1") Integer page, public Object list(String name, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit, @RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "created") String sort, @Sort @RequestParam(defaultValue = "update_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) { @Order @RequestParam(defaultValue = "asc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商品管理->商品管理->查询,请求参数:name:{},page:{}", name, page); logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商品管理->商品管理->查询,请求参数:name:{},page:{}", name, page);
return adminGoodsService.list(name, page, limit, sort, order); return adminGoodsService.list(name, page, limit, sort, order);
...@@ -126,7 +126,6 @@ public class AdminGoodsController { ...@@ -126,7 +126,6 @@ public class AdminGoodsController {
@GetMapping("/detail") @GetMapping("/detail")
public Object detail(@NotNull Long id) { public Object detail(@NotNull Long id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商品管理->商品管理->详情,请求参数,id:{}", id); logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商品管理->商品管理->详情,请求参数,id:{}", id);
return adminGoodsService.detail(id); return adminGoodsService.detail(id);
} }
......
package com.wwdz.ch.admin.controller; package com.wwdz.ch.admin.controller;
import com.alibaba.fastjson.JSONObject;
import com.wwdz.ch.admin.annotation.RequiresPermissionsDesc; import com.wwdz.ch.admin.annotation.RequiresPermissionsDesc;
import com.wwdz.ch.admin.entity.vo.CategoryVo; import com.wwdz.ch.admin.service.ItemService;
import com.wwdz.ch.admin.entity.vo.CoinVo;
import com.wwdz.ch.admin.service.CoinService;
import com.wwdz.ch.admin.util.AuthSupport; import com.wwdz.ch.admin.util.AuthSupport;
import com.wwdz.ch.core.type.ListResult; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.type.SimpleResult;
import com.wwdz.ch.db.domain.Category;
import com.wwdz.ch.db.dto.request.CoinRequestDto; import com.wwdz.ch.db.dto.request.CoinRequestDto;
import com.xxdxxs.utils.JsonUtils; import com.xxdxxs.utils.JsonUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
...@@ -23,31 +18,31 @@ import org.springframework.web.bind.annotation.*; ...@@ -23,31 +18,31 @@ import org.springframework.web.bind.annotation.*;
*/ */
@RestController @RestController
@RequestMapping("/admin/setCoin") @RequestMapping("/admin/setCoin")
public class SetCoinController { public class ItemController {
private static final Logger logger = LoggerFactory.getLogger(SetCoinController.class); private static final Logger logger = LoggerFactory.getLogger(ItemController.class);
@Autowired @Autowired
private CoinService coinService; private ItemService itemService;
@RequiresPermissions("admin:setCoin:findDetail") @RequiresPermissions("admin:setCoin:findDetail")
@RequiresPermissionsDesc(menu = { "钱币列表", "钱币明细" }, button = "查询") @RequiresPermissionsDesc(menu = { "钱币列表", "钱币明细" }, button = "查询")
@PostMapping("/findDetail") @PostMapping("/findDetail")
public SimpleResult<CoinVo> findDetail(@RequestBody CoinRequestDto coinRequestDto) { public Result findDetail(@RequestBody CoinRequestDto coinRequestDto) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 钱币列表->钱币明细->查询,请求参数:parma:{}", coinRequestDto); logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 钱币列表->钱币明细->查询,请求参数:parma:{}", coinRequestDto);
CoinVo coinVo = coinService.findDetails(coinRequestDto); Result result = itemService.findDetails(coinRequestDto);
logger.info("【请求结束】钱币列表->钱币明细->查询:total:{}", JsonUtils.from(coinVo)); logger.info("【请求结束】钱币列表->钱币明细->查询:total:{}", JsonUtils.from(result));
return new SimpleResult<>(coinVo); return result;
} }
@RequiresPermissions("admin:setCoin:update") @RequiresPermissions("admin:setCoin:setCoin")
@RequiresPermissionsDesc(menu = { "钱币列表", "钱币设置" }, button = "更新") @RequiresPermissionsDesc(menu = { "钱币列表", "钱币设置" }, button = "更新")
@PostMapping("/update") @PostMapping("/setCoin")
public Object update(@RequestBody CoinRequestDto coinRequestDto) { public Result setCoin(@RequestBody CoinRequestDto coinRequestDto) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 钱币列表->钱币设置->更新,请求参数:parma:{}", coinRequestDto); logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 钱币列表->钱币设置->更新,请求参数:parma:{}", coinRequestDto);
coinService.setCoin(coinRequestDto); Result result = itemService.setCoin(coinRequestDto);
logger.info("【请求结束】钱币列表->钱币明细->更新"); logger.info("【请求结束】钱币列表->钱币明细->更新");
return new SimpleResult<>(true); return result;
} }
} }
...@@ -89,4 +89,19 @@ public class CoinVo implements Entity { ...@@ -89,4 +89,19 @@ public class CoinVo implements Entity {
* 商品详细介绍,是富文本格式 * 商品详细介绍,是富文本格式
*/ */
private String detail; private String detail;
/**
* 直径
*/
private String diameter;
/**
* 厚度
*/
private String thickness;
/**
* 质量(重量)
*/
private String weight;
} }
package com.wwdz.ch.admin.impl;
import com.wwdz.ch.admin.entity.vo.CoinVo;
import com.wwdz.ch.admin.service.CoinService;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dto.request.CoinRequestDto;
import com.wwdz.ch.db.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CoinServiceImpl implements CoinService {
@Autowired
ItemService itemService;
@Override
public List<CoinVo> findList(CoinRequestDto coinRequestDto) {
return null;
}
@Override
public CoinVo findDetails(CoinRequestDto coinRequestDto) {
return null;
}
@Override
public Result setCoin(CoinRequestDto coinRequestDto) {
return null;
}
}
package com.wwdz.ch.admin.impl;
import com.wwdz.ch.admin.entity.vo.CoinVo;
import com.wwdz.ch.admin.service.ItemService;
import com.wwdz.ch.admin.service.OperateLogService;
import com.wwdz.ch.admin.util.AuthSupport;
import com.wwdz.ch.core.storage.QiniuStorage;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.db.domain.OperateLog;
import com.wwdz.ch.db.dto.request.CoinRequestDto;
import com.wwdz.ch.db.manager.ItemManager;
import com.xxdxxs.utils.EntityMapper;
import com.xxdxxs.utils.JsonUtils;
import com.xxdxxs.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.*;
@Service
public class ItemServiceImpl implements ItemService {
private static final Logger logger = LoggerFactory.getLogger(ItemServiceImpl.class);
private final static String IMG_TYPE = "image/png";
private final static String IMG_SUFFIX = ".png";
@Autowired
ItemManager itemManager;
@Autowired
QiniuStorage qiniuStorage;
@Autowired
OperateLogService operateLogService;
@Override
public List<CoinVo> findList(CoinRequestDto coinRequestDto) {
return null;
}
@Override
public Result findDetails(CoinRequestDto coinRequestDto) {
Map<String, Object> map = new HashMap<>();
try {
//不需要查询新一页数据,则根据id查询明细
if (ObjectUtils.isEmpty(coinRequestDto.getIsRefresh()) || coinRequestDto.getIsRefresh() != 1) {
CoinVo coinVo = new CoinVo();
Item item = itemManager.findDetails(coinRequestDto.getId());
EntityMapper.copyAttribute(item, coinVo);
map.put("isRefresh", 0);
map.put("data", coinVo);
} else {
List<CoinVo> coinVoList = new ArrayList<>();
List<Item> itemList = itemManager.findList(coinRequestDto);
itemList.forEach(coin -> {
CoinVo coinVo = convertEntity(coin);
if (coinVo != null) {
coinVoList.add(coinVo);
}
});
map.put("isRefresh", 1);
map.put("data", coinVoList);
}
} catch (Exception e) {
logger.error("钱币设置查询明细 error : {}", e);
}
return Result.success(map);
}
@Override
public Result setCoin(CoinRequestDto coinRequestDto) {
try {
Item item = new Item();
EntityMapper.copyAttribute(coinRequestDto, item);
//查询原有的数据
Item oldItem = itemManager.findDetails(coinRequestDto.getId());
String extra = oldItem.getExtra();
if (StringUtils.hasLength(extra)) {
Map<String, Object> map = JsonUtils.toMap(extra);
//直径
map.put("diameter", coinRequestDto.getDiameter());
//厚度
map.put("thickness", coinRequestDto.getThickness());
//重量
map.put("weight", coinRequestDto.getWeight());
String extraInfo = JsonUtils.fromMap(map);
item.setExtra(extraInfo);
}
String imgBaseStr = coinRequestDto.getImgBaseStr();
String keyName = String.valueOf(coinRequestDto.getId()) + System.currentTimeMillis() + IMG_SUFFIX ;
qiniuStorage.storeBase64Str(imgBaseStr, IMG_TYPE, keyName);
String url = qiniuStorage.generateUrl(keyName);
item.setTopImage(url);
itemManager.setCoin(item);
//记录钱币设置的操作日志
Map<String, Object> paramMap = JsonUtils.toMap(item.getExtra());
paramMap.remove("s_url");
paramMap.put("topImage", url);
OperateLog operateLog = OperateLog.of("钱币设置", 1, AuthSupport.adminId(), AuthSupport.userName(), JsonUtils.fromMap(paramMap));
operateLogService.insert(operateLog);
} catch (Exception e) {
logger.error("钱币设置 error :{}", e);
return Result.failed();
}
return Result.success();
}
public CoinVo convertEntity(Item item) {
try {
CoinVo coinVo = new CoinVo();
EntityMapper.copyAttribute(item, coinVo);
String extra = item.getExtra();
if (StringUtils.hasLength(extra)) {
Map<String, Object> map = JsonUtils.toMap(extra);
coinVo.setDiameter(map.get("diameter") == null? "": map.get("diameter").toString());
coinVo.setThickness(map.get("thickness")== null? "": map.get("thickness").toString());
coinVo.setWeight(map.get("weight")== null? "": map.get("weight").toString());
}
return coinVo;
} catch (Exception e) {
logger.error("钱币设置 error :{}", e);
}
return null;
}
}
package com.wwdz.ch.admin.impl;
import com.wwdz.ch.admin.service.OperateLogService;
import com.wwdz.ch.db.domain.OperateLog;
import com.wwdz.ch.db.manager.OperateLogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class OperateLogServiceImpl implements OperateLogService {
@Autowired
OperateLogManager operateLogManager;
@Override
public void insert(OperateLog operateLog) {
operateLogManager.insert(operateLog);
}
}
package com.wwdz.ch.admin.service; package com.wwdz.ch.admin.service;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.wwdz.ch.admin.entity.vo.ItemVo; import com.wwdz.ch.admin.entity.vo.ItemVo;
import com.wwdz.ch.db.domain.*; import com.wwdz.ch.db.domain.*;
import com.wwdz.ch.db.service.*; import com.wwdz.ch.db.service.*;
import com.wwdz.ch.db.service.ItemService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -81,7 +81,7 @@ public class AdminGoodsService { ...@@ -81,7 +81,7 @@ public class AdminGoodsService {
Long id = item.getId(); Long id = item.getId();
// 将生成的分享图片地址写入数据库 // 将生成的分享图片地址写入数据库
String url = qCodeService.createGoodShareImage(null,item.getId().toString(), item.getImages().split(";")[0], item.getName(),item.getPrice()); String url = qCodeService.createGoodShareImage(null, item.getId().toString(), item.getImages().split(";")[0], item.getName(), item.getPrice());
item.setShareImage(url); item.setShareImage(url);
// 商品基本信息表Dts_goods // 商品基本信息表Dts_goods
...@@ -119,13 +119,13 @@ public class AdminGoodsService { ...@@ -119,13 +119,13 @@ public class AdminGoodsService {
} }
Date now = new Date(); Date now = new Date();
// 商品基本信息表Dts_goods // 商品基本信息表Dts_goods
item.setCreated(now); item.setCreateTime(now);
item.setUpdated(now); item.setUpdateTime(now);
item.setIsDeleted(false); item.setIsDeleted(false);
itemService.add(item); itemService.add(item);
// 将生成的分享图片地址写入数据库 // 将生成的分享图片地址写入数据库
String url = qCodeService.createGoodShareImage(null,item.getId().toString(), item.getImages().split(";")[0], item.getName(), item.getPrice()); String url = qCodeService.createGoodShareImage(null, item.getId().toString(), item.getImages().split(";")[0], item.getName(), item.getPrice());
if (!StringUtils.isEmpty(url)) { if (!StringUtils.isEmpty(url)) {
item.setShareImage(url); item.setShareImage(url);
if (itemService.updateById(item) == 0) { if (itemService.updateById(item) == 0) {
......
...@@ -6,11 +6,11 @@ import com.wwdz.ch.db.dto.request.CoinRequestDto; ...@@ -6,11 +6,11 @@ import com.wwdz.ch.db.dto.request.CoinRequestDto;
import java.util.List; import java.util.List;
public interface CoinService { public interface ItemService {
List<CoinVo> findList(CoinRequestDto coinRequestDto); List<CoinVo> findList(CoinRequestDto coinRequestDto);
CoinVo findDetails(CoinRequestDto coinRequestDto); Result findDetails(CoinRequestDto coinRequestDto);
Result setCoin(CoinRequestDto coinRequestDto); Result setCoin(CoinRequestDto coinRequestDto);
} }
package com.wwdz.ch.admin.service;
import com.wwdz.ch.db.domain.OperateLog;
public interface OperateLogService {
void insert(OperateLog operateLog);
}
package com.wwdz.ch.core.storage; package com.wwdz.ch.core.storage;
import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Base64;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
...@@ -83,6 +85,21 @@ public class QiniuStorage implements Storage { ...@@ -83,6 +85,21 @@ public class QiniuStorage implements Storage {
} }
} }
public void storeBase64Str(String baseStr, String contentType, String keyName) throws Exception {
if (uploadManager == null) {
if (auth == null) {
auth = Auth.create(accessKey, secretKey);
}
uploadManager = new UploadManager(new Configuration());
}
Base64.Decoder decoder = Base64.getDecoder();
byte[] imageByte = decoder.decode(baseStr.split(",")[1]);
InputStream inputStream = new ByteArrayInputStream(imageByte);
store(inputStream, 1, contentType, keyName);
}
@Override @Override
public Stream<Path> loadAll() { public Stream<Path> loadAll() {
return null; return null;
......
...@@ -2,13 +2,12 @@ package com.wwdz.ch.core.util; ...@@ -2,13 +2,12 @@ package com.wwdz.ch.core.util;
import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.SortOrder; import co.elastic.clients.elasticsearch._types.SortOrder;
import co.elastic.clients.elasticsearch.core.GetRequest;
import co.elastic.clients.elasticsearch.core.GetResponse; import co.elastic.clients.elasticsearch.core.GetResponse;
import co.elastic.clients.elasticsearch.core.SearchRequest; import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse; import co.elastic.clients.elasticsearch.core.SearchResponse;
import co.elastic.clients.util.ObjectBuilder; import co.elastic.clients.util.ObjectBuilder;
import com.wwdz.ch.core.entity.EsSearchParam; import com.wwdz.ch.core.entity.EsSearchParam;
import com.wwdz.ch.db.bean.CoinOfEs; import com.wwdz.ch.db.bean.ItemOfEs;
import com.xxdxxs.entity.Entity; import com.xxdxxs.entity.Entity;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -42,14 +41,14 @@ public class ElasticsearchUtil { ...@@ -42,14 +41,14 @@ public class ElasticsearchUtil {
.order(SortOrder.Desc))); .order(SortOrder.Desc)));
SearchRequest searchRequest = SearchRequest.of((Function<SearchRequest.Builder, ObjectBuilder<SearchRequest>>) builder); SearchRequest searchRequest = SearchRequest.of((Function<SearchRequest.Builder, ObjectBuilder<SearchRequest>>) builder);
SearchResponse<CoinOfEs> searchResponse = elasticsearchClient.search(searchRequest, CoinOfEs.class); SearchResponse<ItemOfEs> searchResponse = elasticsearchClient.search(searchRequest, ItemOfEs.class);
GetResponse<CoinOfEs> response = elasticsearchClient.get(s -> s.index("quanku") GetResponse<ItemOfEs> response = elasticsearchClient.get(s -> s.index("quanku")
.id("e051445c-ae8c-47ef-ab18-97b34025d49a"), CoinOfEs.class); .id("e051445c-ae8c-47ef-ab18-97b34025d49a"), ItemOfEs.class);
logger.info("getResponse:{}", response.source()); logger.info("getResponse:{}", response.source());
if (response.found()) { if (response.found()) {
CoinOfEs coinOfEs = response.source(); ItemOfEs itemOfEs = response.source();
assert coinOfEs != null; assert itemOfEs != null;
logger.info("coin name= {} ", coinOfEs.getName()); logger.info("coin name= {} ", itemOfEs.getName());
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
package com.wwdz.ch.core.util; package com.wwdz.ch.core.util;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.wwdz.ch.db.domain.Item; import com.wwdz.ch.db.domain.Item;
import com.xxdxxs.utils.JsonUtils; import com.xxdxxs.utils.JsonUtils;
...@@ -10,7 +9,6 @@ import org.slf4j.LoggerFactory; ...@@ -10,7 +9,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
......
...@@ -4,15 +4,15 @@ import com.xxdxxs.entity.Entity; ...@@ -4,15 +4,15 @@ import com.xxdxxs.entity.Entity;
import lombok.Data; import lombok.Data;
@Data @Data
public class CoinOfEs implements Entity { public class ItemOfEs implements Entity {
/** /**
* 钱币id * 商品id
*/ */
private String coin_id; private String coin_id;
/** /**
* 钱币名称 * 商品名称
*/ */
private String name; private String name;
......
...@@ -6,7 +6,7 @@ import java.util.List; ...@@ -6,7 +6,7 @@ import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@Mapper
public interface AdminMapper { public interface AdminMapper {
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
......
...@@ -3,8 +3,10 @@ package com.wwdz.ch.db.dao; ...@@ -3,8 +3,10 @@ package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.Item; import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.db.domain.ItemExample; import com.wwdz.ch.db.domain.ItemExample;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface ItemMapper { public interface ItemMapper {
long countByExample(ItemExample example); long countByExample(ItemExample example);
......
package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.OperateLog;
import com.wwdz.ch.db.domain.OperateLogExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface OperateLogMapper {
long countByExample(OperateLogExample example);
int deleteByExample(OperateLogExample example);
int deleteByPrimaryKey(Integer id);
int insert(OperateLog record);
int insertSelective(OperateLog record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table operate_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
OperateLog selectOneByExample(OperateLogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table operate_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
OperateLog selectOneByExampleSelective(@Param("example") OperateLogExample example, @Param("selective") OperateLog.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table operate_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
OperateLog selectOneByExampleWithBLOBs(OperateLogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table operate_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<OperateLog> selectByExampleSelective(@Param("example") OperateLogExample example, @Param("selective") OperateLog.Column ... selective);
List<OperateLog> selectByExampleWithBLOBs(OperateLogExample example);
List<OperateLog> selectByExample(OperateLogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table operate_log
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
OperateLog selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") OperateLog.Column ... selective);
OperateLog selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") OperateLog record, @Param("example") OperateLogExample example);
int updateByExampleWithBLOBs(@Param("record") OperateLog record, @Param("example") OperateLogExample example);
int updateByExample(@Param("record") OperateLog record, @Param("example") OperateLogExample example);
int updateByPrimaryKeySelective(OperateLog record);
int updateByPrimaryKeyWithBLOBs(OperateLog record);
int updateByPrimaryKey(OperateLog record);
}
\ No newline at end of file
...@@ -4,14 +4,16 @@ import java.io.Serializable; ...@@ -4,14 +4,16 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data; import lombok.Data;
/** /**
* @author shiyu * @author shiyu
* @date 2023/07/19 * @date 2023/07/20
*/ */
@Data @Data
public class Item implements Serializable { public class Item implements Entity {
private Long id; private Long id;
/** /**
...@@ -44,6 +46,11 @@ public class Item implements Serializable { ...@@ -44,6 +46,11 @@ public class Item implements Serializable {
*/ */
private String shareImage; private String shareImage;
/**
* 置顶图片
*/
private String topImage;
/** /**
* 价格, 要除以100 * 价格, 要除以100
*/ */
...@@ -52,17 +59,17 @@ public class Item implements Serializable { ...@@ -52,17 +59,17 @@ public class Item implements Serializable {
/** /**
* 创建时间 * 创建时间
*/ */
private Date created; private Date createTime;
/** /**
* 来源类型(1系统2用户上传) * 来源类型(1系统2用户上传)
*/ */
private Boolean sourceType; private Integer sourceType;
/** /**
* 更新时间 * 更新时间
*/ */
private Date updated; private Date updateTime;
/** /**
* 逻辑删除 * 逻辑删除
...@@ -109,10 +116,11 @@ public class Item implements Serializable { ...@@ -109,10 +116,11 @@ public class Item implements Serializable {
sb.append(", isStd=").append(isStd); sb.append(", isStd=").append(isStd);
sb.append(", sort=").append(sort); sb.append(", sort=").append(sort);
sb.append(", shareImage=").append(shareImage); sb.append(", shareImage=").append(shareImage);
sb.append(", topImage=").append(topImage);
sb.append(", price=").append(price); sb.append(", price=").append(price);
sb.append(", created=").append(created); sb.append(", createTime=").append(createTime);
sb.append(", sourceType=").append(sourceType); sb.append(", sourceType=").append(sourceType);
sb.append(", updated=").append(updated); sb.append(", updateTime=").append(updateTime);
sb.append(", isDeleted=").append(isDeleted); sb.append(", isDeleted=").append(isDeleted);
sb.append(", bidTime=").append(bidTime); sb.append(", bidTime=").append(bidTime);
sb.append(", remark=").append(remark); sb.append(", remark=").append(remark);
...@@ -143,10 +151,11 @@ public class Item implements Serializable { ...@@ -143,10 +151,11 @@ public class Item implements Serializable {
&& (this.getIsStd() == null ? other.getIsStd() == null : this.getIsStd().equals(other.getIsStd())) && (this.getIsStd() == null ? other.getIsStd() == null : this.getIsStd().equals(other.getIsStd()))
&& (this.getSort() == null ? other.getSort() == null : this.getSort().equals(other.getSort())) && (this.getSort() == null ? other.getSort() == null : this.getSort().equals(other.getSort()))
&& (this.getShareImage() == null ? other.getShareImage() == null : this.getShareImage().equals(other.getShareImage())) && (this.getShareImage() == null ? other.getShareImage() == null : this.getShareImage().equals(other.getShareImage()))
&& (this.getTopImage() == null ? other.getTopImage() == null : this.getTopImage().equals(other.getTopImage()))
&& (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice())) && (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice()))
&& (this.getCreated() == null ? other.getCreated() == null : this.getCreated().equals(other.getCreated())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getSourceType() == null ? other.getSourceType() == null : this.getSourceType().equals(other.getSourceType())) && (this.getSourceType() == null ? other.getSourceType() == null : this.getSourceType().equals(other.getSourceType()))
&& (this.getUpdated() == null ? other.getUpdated() == null : this.getUpdated().equals(other.getUpdated())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted())) && (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()))
&& (this.getBidTime() == null ? other.getBidTime() == null : this.getBidTime().equals(other.getBidTime())) && (this.getBidTime() == null ? other.getBidTime() == null : this.getBidTime().equals(other.getBidTime()))
&& (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark())) && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
...@@ -166,10 +175,11 @@ public class Item implements Serializable { ...@@ -166,10 +175,11 @@ public class Item implements Serializable {
result = prime * result + ((getIsStd() == null) ? 0 : getIsStd().hashCode()); result = prime * result + ((getIsStd() == null) ? 0 : getIsStd().hashCode());
result = prime * result + ((getSort() == null) ? 0 : getSort().hashCode()); result = prime * result + ((getSort() == null) ? 0 : getSort().hashCode());
result = prime * result + ((getShareImage() == null) ? 0 : getShareImage().hashCode()); result = prime * result + ((getShareImage() == null) ? 0 : getShareImage().hashCode());
result = prime * result + ((getTopImage() == null) ? 0 : getTopImage().hashCode());
result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode()); result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode());
result = prime * result + ((getCreated() == null) ? 0 : getCreated().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getSourceType() == null) ? 0 : getSourceType().hashCode()); result = prime * result + ((getSourceType() == null) ? 0 : getSourceType().hashCode());
result = prime * result + ((getUpdated() == null) ? 0 : getUpdated().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode()); result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
result = prime * result + ((getBidTime() == null) ? 0 : getBidTime().hashCode()); result = prime * result + ((getBidTime() == null) ? 0 : getBidTime().hashCode());
result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode()); result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
...@@ -194,10 +204,11 @@ public class Item implements Serializable { ...@@ -194,10 +204,11 @@ public class Item implements Serializable {
isStd("is_std", "isStd", "BIT", false), isStd("is_std", "isStd", "BIT", false),
sort("sort", "sort", "INTEGER", false), sort("sort", "sort", "INTEGER", false),
shareImage("share_image", "shareImage", "VARCHAR", false), shareImage("share_image", "shareImage", "VARCHAR", false),
topImage("top_image", "topImage", "VARCHAR", false),
price("price", "price", "BIGINT", false), price("price", "price", "BIGINT", false),
created("created", "created", "TIMESTAMP", false), createTime("create_time", "createTime", "TIMESTAMP", false),
sourceType("source_type", "sourceType", "BIT", false), sourceType("source_type", "sourceType", "INTEGER", false),
updated("updated", "updated", "TIMESTAMP", false), updateTime("update_time", "updateTime", "TIMESTAMP", false),
isDeleted("is_deleted", "isDeleted", "BIT", false), isDeleted("is_deleted", "isDeleted", "BIT", false),
bidTime("bid_time", "bidTime", "VARCHAR", false), bidTime("bid_time", "bidTime", "VARCHAR", false),
remark("remark", "remark", "VARCHAR", false), remark("remark", "remark", "VARCHAR", false),
......
This diff is collapsed.
...@@ -6,12 +6,14 @@ import lombok.Data; ...@@ -6,12 +6,14 @@ import lombok.Data;
@Data @Data
public class CoinRequestDto extends BaseRequestDto implements Entity { public class CoinRequestDto extends BaseRequestDto implements Entity {
private Long id;
private String name; private String name;
/** /**
* 钱币所属分类 * 钱币所属分类
*/ */
private String cid; private Integer cid;
/** /**
* 直径 * 直径
...@@ -40,4 +42,10 @@ public class CoinRequestDto extends BaseRequestDto implements Entity { ...@@ -40,4 +42,10 @@ public class CoinRequestDto extends BaseRequestDto implements Entity {
private String imgBaseStr; private String imgBaseStr;
private String remark; private String remark;
/**
* 是否请求新一页的数据
* 0否,1是
*/
private Integer isRefresh;
} }
package com.wwdz.ch.db.manager;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.db.dto.request.CoinRequestDto;
import java.util.List;
public interface ItemManager {
List<Item> findList(CoinRequestDto coinRequestDto);
Item findDetails(Long id);
boolean setCoin(Item item);
}
package com.wwdz.ch.db.manager;
import com.wwdz.ch.db.domain.OperateLog;
public interface OperateLogManager {
void insert(OperateLog operateLog);
}
package com.wwdz.ch.db.manager.impl;
import com.wwdz.ch.db.dao.ItemMapper;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.db.domain.ItemExample;
import com.wwdz.ch.db.dto.request.CoinRequestDto;
import com.wwdz.ch.db.manager.ItemManager;
import com.xxdxxs.db.component.JdbcHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
@Repository
public class ItemManagerImpl implements ItemManager {
@Autowired
ItemMapper itemMapper;
@Override
public List<Item> findList(CoinRequestDto coinRequestDto) {
ItemExample example = new ItemExample();
ItemExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(coinRequestDto.getId(), criteria :: andIdEqualTo);
JdbcHelper.ifPresent(coinRequestDto.getName(), criteria :: andNameLike);
JdbcHelper.ifPresent(coinRequestDto.getCid(), criteria :: andCidEqualTo);
return itemMapper.selectByExample(example);
}
@Override
public Item findDetails(Long id) {
ItemExample example = new ItemExample();
ItemExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(id);
return itemMapper.selectOneByExample(example);
}
@Override
public boolean setCoin(Item item) {
ItemExample example = new ItemExample();
ItemExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(item.getId());
item.setUpdateTime(new Date());
int num = itemMapper.updateByExampleSelective(item, example);
return num > 0;
}
}
package com.wwdz.ch.db.manager.impl;
import com.wwdz.ch.db.dao.OperateLogMapper;
import com.wwdz.ch.db.domain.OperateLog;
import com.wwdz.ch.db.manager.OperateLogManager;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Repository
public class OperateLogManagerImpl implements OperateLogManager {
@Mapper
OperateLogMapper operateLogMapper;
@Override
public void insert(OperateLog operateLog) {
operateLogMapper.insert(operateLog);
}
}
...@@ -8,7 +8,6 @@ import org.springframework.stereotype.Service; ...@@ -8,7 +8,6 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -53,7 +52,7 @@ public class ItemService { ...@@ -53,7 +52,7 @@ public class ItemService {
} }
public List<Item> querySelective(Integer catId, String keywords, public List<Item> querySelective(Integer catId, String keywords,
Integer offset, Integer limit, String sort, String order) { Integer offset, Integer limit, String sort, String order) {
ItemExample example = new ItemExample(); ItemExample example = new ItemExample();
ItemExample.Criteria criteria1 = example.or(); ItemExample.Criteria criteria1 = example.or();
...@@ -76,7 +75,7 @@ public class ItemService { ...@@ -76,7 +75,7 @@ public class ItemService {
} }
public List<Item> querySelective(String name, Integer page, Integer size, String sort, public List<Item> querySelective(String name, Integer page, Integer size, String sort,
String order) { String order) {
ItemExample example = new ItemExample(); ItemExample example = new ItemExample();
ItemExample.Criteria criteria = example.createCriteria(); ItemExample.Criteria criteria = example.createCriteria();
...@@ -118,7 +117,7 @@ public class ItemService { ...@@ -118,7 +117,7 @@ public class ItemService {
} }
public int updateById(Item item) { public int updateById(Item item) {
item.setUpdated(new Date()); item.setUpdateTime(new Date());
return itemMapper.updateByPrimaryKeySelective(item); return itemMapper.updateByPrimaryKeySelective(item);
} }
...@@ -128,8 +127,8 @@ public class ItemService { ...@@ -128,8 +127,8 @@ public class ItemService {
public void add(Item item) { public void add(Item item) {
Date now = new Date(); Date now = new Date();
item.setCreated(now); item.setCreateTime(now);
item.setUpdated(now); item.setUpdateTime(now);
itemMapper.insertSelective(item); itemMapper.insertSelective(item);
} }
......
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