Commit a0514228 authored by shiyu's avatar shiyu

钱币设置

parent 289005df
......@@ -64,8 +64,8 @@ public class AdminGoodsController {
@GetMapping("/list")
public Object list(String name, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "created") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
@Sort @RequestParam(defaultValue = "update_time") String sort,
@Order @RequestParam(defaultValue = "asc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商品管理->商品管理->查询,请求参数:name:{},page:{}", name, page);
return adminGoodsService.list(name, page, limit, sort, order);
......@@ -126,7 +126,6 @@ public class AdminGoodsController {
@GetMapping("/detail")
public Object detail(@NotNull Long id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商品管理->商品管理->详情,请求参数,id:{}", id);
return adminGoodsService.detail(id);
}
......
package com.wwdz.ch.admin.controller;
import com.alibaba.fastjson.JSONObject;
import com.wwdz.ch.admin.annotation.RequiresPermissionsDesc;
import com.wwdz.ch.admin.entity.vo.CategoryVo;
import com.wwdz.ch.admin.entity.vo.CoinVo;
import com.wwdz.ch.admin.service.CoinService;
import com.wwdz.ch.admin.service.ItemService;
import com.wwdz.ch.admin.util.AuthSupport;
import com.wwdz.ch.core.type.ListResult;
import com.wwdz.ch.core.type.SimpleResult;
import com.wwdz.ch.db.domain.Category;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dto.request.CoinRequestDto;
import com.xxdxxs.utils.JsonUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -23,31 +18,31 @@ import org.springframework.web.bind.annotation.*;
*/
@RestController
@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
private CoinService coinService;
private ItemService itemService;
@RequiresPermissions("admin:setCoin:findDetail")
@RequiresPermissionsDesc(menu = { "钱币列表", "钱币明细" }, button = "查询")
@PostMapping("/findDetail")
public SimpleResult<CoinVo> findDetail(@RequestBody CoinRequestDto coinRequestDto) {
public Result findDetail(@RequestBody CoinRequestDto coinRequestDto) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 钱币列表->钱币明细->查询,请求参数:parma:{}", coinRequestDto);
CoinVo coinVo = coinService.findDetails(coinRequestDto);
logger.info("【请求结束】钱币列表->钱币明细->查询:total:{}", JsonUtils.from(coinVo));
return new SimpleResult<>(coinVo);
Result result = itemService.findDetails(coinRequestDto);
logger.info("【请求结束】钱币列表->钱币明细->查询:total:{}", JsonUtils.from(result));
return result;
}
@RequiresPermissions("admin:setCoin:update")
@RequiresPermissions("admin:setCoin:setCoin")
@RequiresPermissionsDesc(menu = { "钱币列表", "钱币设置" }, button = "更新")
@PostMapping("/update")
public Object update(@RequestBody CoinRequestDto coinRequestDto) {
@PostMapping("/setCoin")
public Result setCoin(@RequestBody CoinRequestDto coinRequestDto) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 钱币列表->钱币设置->更新,请求参数:parma:{}", coinRequestDto);
coinService.setCoin(coinRequestDto);
Result result = itemService.setCoin(coinRequestDto);
logger.info("【请求结束】钱币列表->钱币明细->更新");
return new SimpleResult<>(true);
return result;
}
}
......@@ -89,4 +89,19 @@ public class CoinVo implements Entity {
* 商品详细介绍,是富文本格式
*/
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;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import com.wwdz.ch.admin.entity.vo.ItemVo;
import com.wwdz.ch.db.domain.*;
import com.wwdz.ch.db.service.*;
import com.wwdz.ch.db.service.ItemService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -81,7 +81,7 @@ public class AdminGoodsService {
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);
// 商品基本信息表Dts_goods
......@@ -119,13 +119,13 @@ public class AdminGoodsService {
}
Date now = new Date();
// 商品基本信息表Dts_goods
item.setCreated(now);
item.setUpdated(now);
item.setCreateTime(now);
item.setUpdateTime(now);
item.setIsDeleted(false);
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)) {
item.setShareImage(url);
if (itemService.updateById(item) == 0) {
......
......@@ -6,11 +6,11 @@ import com.wwdz.ch.db.dto.request.CoinRequestDto;
import java.util.List;
public interface CoinService {
public interface ItemService {
List<CoinVo> findList(CoinRequestDto coinRequestDto);
CoinVo findDetails(CoinRequestDto coinRequestDto);
Result findDetails(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;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.util.Base64;
import java.util.stream.Stream;
import org.apache.commons.logging.Log;
......@@ -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
public Stream<Path> loadAll() {
return null;
......
......@@ -2,13 +2,12 @@ package com.wwdz.ch.core.util;
import co.elastic.clients.elasticsearch.ElasticsearchClient;
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.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse;
import co.elastic.clients.util.ObjectBuilder;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -42,14 +41,14 @@ public class ElasticsearchUtil {
.order(SortOrder.Desc)));
SearchRequest searchRequest = SearchRequest.of((Function<SearchRequest.Builder, ObjectBuilder<SearchRequest>>) builder);
SearchResponse<CoinOfEs> searchResponse = elasticsearchClient.search(searchRequest, CoinOfEs.class);
GetResponse<CoinOfEs> response = elasticsearchClient.get(s -> s.index("quanku")
.id("e051445c-ae8c-47ef-ab18-97b34025d49a"), CoinOfEs.class);
SearchResponse<ItemOfEs> searchResponse = elasticsearchClient.search(searchRequest, ItemOfEs.class);
GetResponse<ItemOfEs> response = elasticsearchClient.get(s -> s.index("quanku")
.id("e051445c-ae8c-47ef-ab18-97b34025d49a"), ItemOfEs.class);
logger.info("getResponse:{}", response.source());
if (response.found()) {
CoinOfEs coinOfEs = response.source();
assert coinOfEs != null;
logger.info("coin name= {} ", coinOfEs.getName());
ItemOfEs itemOfEs = response.source();
assert itemOfEs != null;
logger.info("coin name= {} ", itemOfEs.getName());
}
} catch (Exception e) {
e.printStackTrace();
......
package com.wwdz.ch.core.util;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.wwdz.ch.db.domain.Item;
import com.xxdxxs.utils.JsonUtils;
......@@ -10,7 +9,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import java.io.Serializable;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.util.*;
......
......@@ -4,15 +4,15 @@ import com.xxdxxs.entity.Entity;
import lombok.Data;
@Data
public class CoinOfEs implements Entity {
public class ItemOfEs implements Entity {
/**
* 钱币id
* 商品id
*/
private String coin_id;
/**
* 钱币名称
* 商品名称
*/
private String name;
......
......@@ -6,7 +6,7 @@ import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface AdminMapper {
/**
* This method was generated by MyBatis Generator.
......
......@@ -3,8 +3,10 @@ package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.db.domain.ItemExample;
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 {
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;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
* @author shiyu
* @date 2023/07/19
* @date 2023/07/20
*/
@Data
public class Item implements Serializable {
public class Item implements Entity {
private Long id;
/**
......@@ -44,6 +46,11 @@ public class Item implements Serializable {
*/
private String shareImage;
/**
* 置顶图片
*/
private String topImage;
/**
* 价格, 要除以100
*/
......@@ -52,17 +59,17 @@ public class Item implements Serializable {
/**
* 创建时间
*/
private Date created;
private Date createTime;
/**
* 来源类型(1系统2用户上传)
*/
private Boolean sourceType;
private Integer sourceType;
/**
* 更新时间
*/
private Date updated;
private Date updateTime;
/**
* 逻辑删除
......@@ -109,10 +116,11 @@ public class Item implements Serializable {
sb.append(", isStd=").append(isStd);
sb.append(", sort=").append(sort);
sb.append(", shareImage=").append(shareImage);
sb.append(", topImage=").append(topImage);
sb.append(", price=").append(price);
sb.append(", created=").append(created);
sb.append(", createTime=").append(createTime);
sb.append(", sourceType=").append(sourceType);
sb.append(", updated=").append(updated);
sb.append(", updateTime=").append(updateTime);
sb.append(", isDeleted=").append(isDeleted);
sb.append(", bidTime=").append(bidTime);
sb.append(", remark=").append(remark);
......@@ -143,10 +151,11 @@ public class Item implements Serializable {
&& (this.getIsStd() == null ? other.getIsStd() == null : this.getIsStd().equals(other.getIsStd()))
&& (this.getSort() == null ? other.getSort() == null : this.getSort().equals(other.getSort()))
&& (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.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.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.getBidTime() == null ? other.getBidTime() == null : this.getBidTime().equals(other.getBidTime()))
&& (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
......@@ -166,10 +175,11 @@ public class Item implements Serializable {
result = prime * result + ((getIsStd() == null) ? 0 : getIsStd().hashCode());
result = prime * result + ((getSort() == null) ? 0 : getSort().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 + ((getCreated() == null) ? 0 : getCreated().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().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 + ((getBidTime() == null) ? 0 : getBidTime().hashCode());
result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
......@@ -194,10 +204,11 @@ public class Item implements Serializable {
isStd("is_std", "isStd", "BIT", false),
sort("sort", "sort", "INTEGER", false),
shareImage("share_image", "shareImage", "VARCHAR", false),
topImage("top_image", "topImage", "VARCHAR", false),
price("price", "price", "BIGINT", false),
created("created", "created", "TIMESTAMP", false),
sourceType("source_type", "sourceType", "BIT", false),
updated("updated", "updated", "TIMESTAMP", false),
createTime("create_time", "createTime", "TIMESTAMP", false),
sourceType("source_type", "sourceType", "INTEGER", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false),
isDeleted("is_deleted", "isDeleted", "BIT", false),
bidTime("bid_time", "bidTime", "VARCHAR", false),
remark("remark", "remark", "VARCHAR", false),
......
This diff is collapsed.
......@@ -6,12 +6,14 @@ import lombok.Data;
@Data
public class CoinRequestDto extends BaseRequestDto implements Entity {
private Long id;
private String name;
/**
* 钱币所属分类
*/
private String cid;
private Integer cid;
/**
* 直径
......@@ -40,4 +42,10 @@ public class CoinRequestDto extends BaseRequestDto implements Entity {
private String imgBaseStr;
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;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
......@@ -118,7 +117,7 @@ public class ItemService {
}
public int updateById(Item item) {
item.setUpdated(new Date());
item.setUpdateTime(new Date());
return itemMapper.updateByPrimaryKeySelective(item);
}
......@@ -128,8 +127,8 @@ public class ItemService {
public void add(Item item) {
Date now = new Date();
item.setCreated(now);
item.setUpdated(now);
item.setCreateTime(now);
item.setUpdateTime(now);
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