Commit bbf82a07 authored by muhong's avatar muhong

修改 钱柜收藏册

parent 68e3c6d7
package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.FavoritesCoinsRelation;
import com.wwdz.ch.db.domain.FavoritesCoinsRelationExample;
import java.util.List;
import com.wwdz.ch.db.domain.FavoritesItemsRelation;
import com.wwdz.ch.db.domain.FavoritesItemsRelationExample;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface FavoritesCoinsRelationMapper {
long countByExample(FavoritesCoinsRelationExample example);
import java.util.List;
int deleteByExample(FavoritesCoinsRelationExample example);
@Mapper
public interface FavoritesItemsRelationMapper {
long countByExample(FavoritesItemsRelationExample example);
int insert(FavoritesCoinsRelation record);
int deleteByExample(FavoritesItemsRelationExample example);
int batchInsert(List<FavoritesCoinsRelation> list);
int insert(FavoritesItemsRelation record);
int insertSelective(FavoritesCoinsRelation record);
int batchInsert(List<FavoritesItemsRelation> list);
int insertSelective(FavoritesItemsRelation record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
FavoritesCoinsRelation selectOneByExample(FavoritesCoinsRelationExample example);
FavoritesItemsRelation selectOneByExample(FavoritesItemsRelationExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
FavoritesCoinsRelation selectOneByExampleSelective(@Param("example") FavoritesCoinsRelationExample example, @Param("selective") FavoritesCoinsRelation.Column ... selective);
FavoritesItemsRelation selectOneByExampleSelective(@Param("example") FavoritesItemsRelationExample example, @Param("selective") FavoritesItemsRelation.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<FavoritesCoinsRelation> selectByExampleSelective(@Param("example") FavoritesCoinsRelationExample example, @Param("selective") FavoritesCoinsRelation.Column ... selective);
List<FavoritesItemsRelation> selectByExampleSelective(@Param("example") FavoritesItemsRelationExample example, @Param("selective") FavoritesItemsRelation.Column ... selective);
List<FavoritesCoinsRelation> selectByExample(FavoritesCoinsRelationExample example);
List<FavoritesItemsRelation> selectByExample(FavoritesItemsRelationExample example);
int updateByExampleSelective(@Param("record") FavoritesCoinsRelation record, @Param("example") FavoritesCoinsRelationExample example);
int updateByExampleSelective(@Param("record") FavoritesItemsRelation record, @Param("example") FavoritesItemsRelationExample example);
int updateByExample(@Param("record") FavoritesCoinsRelation record, @Param("example") FavoritesCoinsRelationExample example);
int updateByExample(@Param("record") FavoritesItemsRelation record, @Param("example") FavoritesItemsRelationExample example);
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.Favorites;
import com.wwdz.ch.db.domain.FavoritesExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
......
package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.UsersItemsRelation;
import com.wwdz.ch.db.domain.UsersItemsRelationExample;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface UsersItemsRelationMapper {
long countByExample(UsersItemsRelationExample example);
int deleteByExample(UsersItemsRelationExample example);
int insert(UsersItemsRelation record);
int insertSelective(UsersItemsRelation record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table users_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UsersItemsRelation selectOneByExample(UsersItemsRelationExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table users_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UsersItemsRelation selectOneByExampleSelective(@Param("example") UsersItemsRelationExample example, @Param("selective") UsersItemsRelation.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table users_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<UsersItemsRelation> selectByExampleSelective(@Param("example") UsersItemsRelationExample example, @Param("selective") UsersItemsRelation.Column ... selective);
List<UsersItemsRelation> selectByExample(UsersItemsRelationExample example);
int updateByExampleSelective(@Param("record") UsersItemsRelation record, @Param("example") UsersItemsRelationExample example);
int updateByExample(@Param("record") UsersItemsRelation record, @Param("example") UsersItemsRelationExample example);
}
\ No newline at end of file
package com.wwdz.ch.db.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import lombok.Data;
/**
* @author shiyu
* @date 2023/07/18
* @date 2023/07/21
*/
@Data
public class Favorites implements Serializable {
......@@ -35,7 +36,7 @@ public class Favorites implements Serializable {
/**
* 用户id
*/
private Long uid;
private Long userId;
/**
* 标题
......@@ -76,7 +77,7 @@ public class Favorites implements Serializable {
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", uid=").append(uid);
sb.append(", userId=").append(userId);
sb.append(", title=").append(title);
sb.append(", description=").append(description);
sb.append(", addTime=").append(addTime);
......@@ -101,7 +102,7 @@ public class Favorites implements Serializable {
}
Favorites other = (Favorites) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getUid() == null ? other.getUid() == null : this.getUid().equals(other.getUid()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
&& (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()))
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
......@@ -115,7 +116,7 @@ public class Favorites implements Serializable {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getUid() == null) ? 0 : getUid().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
......@@ -145,7 +146,7 @@ public class Favorites implements Serializable {
*/
public enum Column {
id("id", "id", "BIGINT", false),
uid("uid", "uid", "BIGINT", true),
userId("user_id", "userId", "BIGINT", false),
title("title", "title", "VARCHAR", false),
description("description", "description", "VARCHAR", false),
addTime("add_time", "addTime", "TIMESTAMP", false),
......
......@@ -280,18 +280,18 @@ public class FavoritesExample {
return (Criteria) this;
}
public Criteria andUidIsNull() {
addCriterion("`uid` is null");
public Criteria andUserIdIsNull() {
addCriterion("user_id is null");
return (Criteria) this;
}
public Criteria andUidIsNotNull() {
addCriterion("`uid` is not null");
public Criteria andUserIdIsNotNull() {
addCriterion("user_id is not null");
return (Criteria) this;
}
public Criteria andUidEqualTo(Long value) {
addCriterion("`uid` =", value, "uid");
public Criteria andUserIdEqualTo(Long value) {
addCriterion("user_id =", value, "userId");
return (Criteria) this;
}
......@@ -302,13 +302,13 @@ public class FavoritesExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUidEqualToColumn(Favorites.Column column) {
addCriterion(new StringBuilder("`uid` = ").append(column.getEscapedColumnName()).toString());
public Criteria andUserIdEqualToColumn(Favorites.Column column) {
addCriterion(new StringBuilder("user_id = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUidNotEqualTo(Long value) {
addCriterion("`uid` <>", value, "uid");
public Criteria andUserIdNotEqualTo(Long value) {
addCriterion("user_id <>", value, "userId");
return (Criteria) this;
}
......@@ -319,13 +319,13 @@ public class FavoritesExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUidNotEqualToColumn(Favorites.Column column) {
addCriterion(new StringBuilder("`uid` <> ").append(column.getEscapedColumnName()).toString());
public Criteria andUserIdNotEqualToColumn(Favorites.Column column) {
addCriterion(new StringBuilder("user_id <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUidGreaterThan(Long value) {
addCriterion("`uid` >", value, "uid");
public Criteria andUserIdGreaterThan(Long value) {
addCriterion("user_id >", value, "userId");
return (Criteria) this;
}
......@@ -336,13 +336,13 @@ public class FavoritesExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUidGreaterThanColumn(Favorites.Column column) {
addCriterion(new StringBuilder("`uid` > ").append(column.getEscapedColumnName()).toString());
public Criteria andUserIdGreaterThanColumn(Favorites.Column column) {
addCriterion(new StringBuilder("user_id > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUidGreaterThanOrEqualTo(Long value) {
addCriterion("`uid` >=", value, "uid");
public Criteria andUserIdGreaterThanOrEqualTo(Long value) {
addCriterion("user_id >=", value, "userId");
return (Criteria) this;
}
......@@ -353,13 +353,13 @@ public class FavoritesExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUidGreaterThanOrEqualToColumn(Favorites.Column column) {
addCriterion(new StringBuilder("`uid` >= ").append(column.getEscapedColumnName()).toString());
public Criteria andUserIdGreaterThanOrEqualToColumn(Favorites.Column column) {
addCriterion(new StringBuilder("user_id >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUidLessThan(Long value) {
addCriterion("`uid` <", value, "uid");
public Criteria andUserIdLessThan(Long value) {
addCriterion("user_id <", value, "userId");
return (Criteria) this;
}
......@@ -370,13 +370,13 @@ public class FavoritesExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUidLessThanColumn(Favorites.Column column) {
addCriterion(new StringBuilder("`uid` < ").append(column.getEscapedColumnName()).toString());
public Criteria andUserIdLessThanColumn(Favorites.Column column) {
addCriterion(new StringBuilder("user_id < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUidLessThanOrEqualTo(Long value) {
addCriterion("`uid` <=", value, "uid");
public Criteria andUserIdLessThanOrEqualTo(Long value) {
addCriterion("user_id <=", value, "userId");
return (Criteria) this;
}
......@@ -387,28 +387,28 @@ public class FavoritesExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUidLessThanOrEqualToColumn(Favorites.Column column) {
addCriterion(new StringBuilder("`uid` <= ").append(column.getEscapedColumnName()).toString());
public Criteria andUserIdLessThanOrEqualToColumn(Favorites.Column column) {
addCriterion(new StringBuilder("user_id <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUidIn(List<Long> values) {
addCriterion("`uid` in", values, "uid");
public Criteria andUserIdIn(List<Long> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andUidNotIn(List<Long> values) {
addCriterion("`uid` not in", values, "uid");
public Criteria andUserIdNotIn(List<Long> values) {
addCriterion("user_id not in", values, "userId");
return (Criteria) this;
}
public Criteria andUidBetween(Long value1, Long value2) {
addCriterion("`uid` between", value1, value2, "uid");
public Criteria andUserIdBetween(Long value1, Long value2) {
addCriterion("user_id between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andUidNotBetween(Long value1, Long value2) {
addCriterion("`uid` not between", value1, value2, "uid");
public Criteria andUserIdNotBetween(Long value1, Long value2) {
addCriterion("user_id not between", value1, value2, "userId");
return (Criteria) this;
}
......
......@@ -3,14 +3,15 @@ package com.wwdz.ch.db.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import lombok.Data;
/**
* @author shiyu
* @date 2023/07/18
* @date 2023/07/21
*/
@Data
public class FavoritesCoinsRelation implements Serializable {
public class FavoritesItemsRelation implements Serializable {
/**
* 收藏册id
*/
......@@ -19,7 +20,12 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* 钱币id
*/
private Long coinsId;
private Long itemId;
/**
* 创建时间
*/
private Date addTime;
private static final long serialVersionUID = 1L;
......@@ -30,7 +36,8 @@ public class FavoritesCoinsRelation implements Serializable {
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", favoritesId=").append(favoritesId);
sb.append(", coinsId=").append(coinsId);
sb.append(", itemId=").append(itemId);
sb.append(", addTime=").append(addTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
......@@ -47,9 +54,10 @@ public class FavoritesCoinsRelation implements Serializable {
if (getClass() != that.getClass()) {
return false;
}
FavoritesCoinsRelation other = (FavoritesCoinsRelation) that;
FavoritesItemsRelation other = (FavoritesItemsRelation) that;
return (this.getFavoritesId() == null ? other.getFavoritesId() == null : this.getFavoritesId().equals(other.getFavoritesId()))
&& (this.getCoinsId() == null ? other.getCoinsId() == null : this.getCoinsId().equals(other.getCoinsId()));
&& (this.getItemId() == null ? other.getItemId() == null : this.getItemId().equals(other.getItemId()))
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()));
}
@Override
......@@ -57,24 +65,26 @@ public class FavoritesCoinsRelation implements Serializable {
final int prime = 31;
int result = 1;
result = prime * result + ((getFavoritesId() == null) ? 0 : getFavoritesId().hashCode());
result = prime * result + ((getCoinsId() == null) ? 0 : getCoinsId().hashCode());
result = prime * result + ((getItemId() == null) ? 0 : getItemId().hashCode());
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
return result;
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table favorites_coins_relation
* This enum corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
favoritesId("favorites_id", "favoritesId", "BIGINT", false),
coinsId("coins_id", "coinsId", "BIGINT", false);
itemId("item_id", "itemId", "BIGINT", false),
addTime("add_time", "addTime", "TIMESTAMP", false);
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table favorites_coins_relation
* This field corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -83,7 +93,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table favorites_coins_relation
* This field corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -92,7 +102,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table favorites_coins_relation
* This field corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -101,7 +111,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table favorites_coins_relation
* This field corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -110,7 +120,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table favorites_coins_relation
* This field corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -119,7 +129,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table favorites_coins_relation
* This field corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -128,7 +138,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -139,7 +149,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -150,7 +160,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -161,7 +171,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -172,7 +182,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -186,7 +196,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -197,7 +207,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -208,7 +218,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -223,7 +233,7 @@ public class FavoritesCoinsRelation implements Serializable {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table favorites_coins_relation
* This method corresponds to the database table favorites_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......
package com.wwdz.ch.db.domain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import lombok.Data;
/**
* @author shiyu
* @date 2023/07/21
*/
@Data
public class UsersItemsRelation implements Serializable {
/**
* 用户id
*/
private Long userId;
/**
* 钱币id
*/
private Long itemId;
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(", userId=").append(userId);
sb.append(", itemId=").append(itemId);
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;
}
UsersItemsRelation other = (UsersItemsRelation) that;
return (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getItemId() == null ? other.getItemId() == null : this.getItemId().equals(other.getItemId()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getItemId() == null) ? 0 : getItemId().hashCode());
return result;
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table users_items_relation
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
userId("user_id", "userId", "BIGINT", false),
itemId("item_id", "itemId", "BIGINT", false);
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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 users_items_relation
*
* @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
......@@ -56,4 +56,9 @@ public class CoinRequestDto extends BaseRequestDto implements Entity {
* 查询时要排除
*/
private List<Long> idExcludeList;
/**
* ids
*/
private List<Long> ids;
}
package com.wwdz.ch.db.manager;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.db.domain.FavoritesCoinsRelation;
import com.wwdz.ch.db.domain.FavoritesItemsRelation;
import java.util.List;
public interface FavoritesCoinsRelationManager {
int add(FavoritesCoinsRelation record);
int batchAdd(List<FavoritesCoinsRelation> list);
public interface FavoritesItemsRelationManager {
int add(FavoritesItemsRelation record);
int batchAdd(List<FavoritesItemsRelation> list);
int deleteByFavoritesId(Long favoritesId, List<Long> favoritesIds);
List<FavoritesCoinsRelation> listByFavoritesId(Long favoritesId, List<Long> favoritesIds);
PageInfo<FavoritesCoinsRelation> pageByFavoritesId(Long favoritesId, int page, int size);
int deleteByChosen(Long favoritesId, List<Long> itemIds);
List<FavoritesItemsRelation> listByFavoritesId(Long favoritesId, List<Long> favoritesIds);
PageInfo<FavoritesItemsRelation> pageByFavoritesId(Long favoritesId, int page, int size);
}
......@@ -11,9 +11,9 @@ public interface FavoritesManager {
int update(Favorites record);
Favorites info(Long id);
PageInfo<Favorites> pageByUid(Long uid, int page, int size);
PageInfo<Favorites> pageByUserId(Long userId, int page, int size);
boolean isExisted(Long id, Long uid, String title);
boolean isExisted(Long id, Long userId, String title);
int delete(Long id, List<Long> ids);
}
......@@ -15,4 +15,6 @@ public interface ItemManager {
Item findDetails(Long id);
boolean setCoin(Item item);
int deleteUserItems(CoinRequestDto coinRequestDto);
}
package com.wwdz.ch.db.manager;
import com.wwdz.ch.db.domain.UsersItemsRelation;
import java.util.List;
public interface UsersItemsRelationManager {
List<UsersItemsRelation> listByUserIds(Long userId, List<Long> userIds);
}
package com.wwdz.ch.db.manager.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.db.dao.FavoritesCoinsRelationMapper;
import com.wwdz.ch.db.domain.FavoritesCoinsRelation;
import com.wwdz.ch.db.domain.FavoritesCoinsRelationExample;
import com.wwdz.ch.db.manager.FavoritesCoinsRelationManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils;
import java.util.List;
@Repository
public class FavoritesCoinsRelationManagerImpl implements FavoritesCoinsRelationManager {
@Autowired
private FavoritesCoinsRelationMapper favoritesCoinsRelationMapper;
@Override
public int add(FavoritesCoinsRelation record) {
return favoritesCoinsRelationMapper.insert(record);
}
@Override
public int batchAdd(List<FavoritesCoinsRelation> list) {
return favoritesCoinsRelationMapper.batchInsert(list);
}
@Override
public int deleteByFavoritesId(Long favoritesId, List<Long> favoritesIds) {
FavoritesCoinsRelationExample example = new FavoritesCoinsRelationExample();
FavoritesCoinsRelationExample.Criteria criteria = example.createCriteria();
if (!CollectionUtils.isEmpty(favoritesIds)) {
criteria.andFavoritesIdIn(favoritesIds);
} else {
criteria.andFavoritesIdEqualTo(favoritesId);
}
return favoritesCoinsRelationMapper.deleteByExample(example);
}
@Override
public List<FavoritesCoinsRelation> listByFavoritesId(Long favoritesId, List<Long> favoritesIds) {
FavoritesCoinsRelationExample example = new FavoritesCoinsRelationExample();
FavoritesCoinsRelationExample.Criteria criteria = example.createCriteria();
if (!CollectionUtils.isEmpty(favoritesIds)) {
criteria.andFavoritesIdIn(favoritesIds);
} else {
criteria.andFavoritesIdEqualTo(favoritesId);
}
return favoritesCoinsRelationMapper.selectByExample(example);
}
@Override
public PageInfo<FavoritesCoinsRelation> pageByFavoritesId(Long favoritesId, int page, int size) {
FavoritesCoinsRelationExample example = new FavoritesCoinsRelationExample();
FavoritesCoinsRelationExample.Criteria criteria = example.createCriteria();
criteria.andFavoritesIdEqualTo(favoritesId);
PageHelper.startPage(page, size);
List<FavoritesCoinsRelation> list = favoritesCoinsRelationMapper.selectByExample(example);
return new PageInfo<>(list);
}
}
package com.wwdz.ch.db.manager.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.db.dao.FavoritesItemsRelationMapper;
import com.wwdz.ch.db.domain.FavoritesItemsRelation;
import com.wwdz.ch.db.domain.FavoritesItemsRelationExample;
import com.wwdz.ch.db.manager.FavoritesItemsRelationManager;
import com.xxdxxs.db.component.JdbcHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class FavoritesItemsRelationManagerImpl implements FavoritesItemsRelationManager {
@Autowired
private FavoritesItemsRelationMapper favoritesItemsRelationMapper;
@Override
public int add(FavoritesItemsRelation record) {
return favoritesItemsRelationMapper.insert(record);
}
@Override
public int batchAdd(List<FavoritesItemsRelation> list) {
return favoritesItemsRelationMapper.batchInsert(list);
}
@Override
public int deleteByFavoritesId(Long favoritesId, List<Long> favoritesIds) {
FavoritesItemsRelationExample example = new FavoritesItemsRelationExample();
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(favoritesId, criteria::andFavoritesIdEqualTo);
JdbcHelper.ifPresent(favoritesIds, criteria::andFavoritesIdIn);
return favoritesItemsRelationMapper.deleteByExample(example);
}
@Override
public int deleteByChosen(Long favoritesId, List<Long> itemIds) {
FavoritesItemsRelationExample example = new FavoritesItemsRelationExample();
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
criteria.andFavoritesIdEqualTo(favoritesId);
criteria.andItemIdIn(itemIds);
return favoritesItemsRelationMapper.deleteByExample(example);
}
@Override
public List<FavoritesItemsRelation> listByFavoritesId(Long favoritesId, List<Long> favoritesIds) {
FavoritesItemsRelationExample example = new FavoritesItemsRelationExample();
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(favoritesId, criteria::andFavoritesIdEqualTo);
JdbcHelper.ifPresent(favoritesIds, criteria::andFavoritesIdIn);
return favoritesItemsRelationMapper.selectByExample(example);
}
@Override
public PageInfo<FavoritesItemsRelation> pageByFavoritesId(Long favoritesId, int page, int size) {
FavoritesItemsRelationExample example = new FavoritesItemsRelationExample();
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
criteria.andFavoritesIdEqualTo(favoritesId);
PageHelper.startPage(page, size);
List<FavoritesItemsRelation> list = favoritesItemsRelationMapper.selectByExample(example);
return new PageInfo<>(list);
}
}
......@@ -6,9 +6,9 @@ import com.wwdz.ch.db.dao.FavoritesMapper;
import com.wwdz.ch.db.domain.Favorites;
import com.wwdz.ch.db.domain.FavoritesExample;
import com.wwdz.ch.db.manager.FavoritesManager;
import com.xxdxxs.db.component.JdbcHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
......@@ -44,10 +44,10 @@ public class FavoritesManagerImpl implements FavoritesManager {
}
@Override
public PageInfo<Favorites> pageByUid(Long uid, int page, int size) {
public PageInfo<Favorites> pageByUserId(Long userId, int page, int size) {
FavoritesExample example = new FavoritesExample();
FavoritesExample.Criteria criteria = example.createCriteria();
criteria.andUidEqualTo(uid);
criteria.andUserIdEqualTo(userId);
criteria.andDeletedEqualTo(false);
PageHelper.startPage(page, size);
List<Favorites> list = favoritesMapper.selectByExample(example);
......@@ -55,10 +55,10 @@ public class FavoritesManagerImpl implements FavoritesManager {
}
@Override
public boolean isExisted(Long id, Long uid, String title) {
public boolean isExisted(Long id, Long userId, String title) {
FavoritesExample example = new FavoritesExample();
FavoritesExample.Criteria criteria = example.createCriteria();
criteria.andUidEqualTo(uid);
criteria.andUserIdEqualTo(userId);
criteria.andTitleEqualTo(title);
criteria.andDeletedEqualTo(false);
if (Objects.nonNull(id)) {
......@@ -71,11 +71,8 @@ public class FavoritesManagerImpl implements FavoritesManager {
public int delete(Long id, List<Long> ids) {
FavoritesExample example = new FavoritesExample();
FavoritesExample.Criteria criteria = example.createCriteria();
if (!CollectionUtils.isEmpty(ids)) {
criteria.andIdIn(ids);
} else {
criteria.andIdEqualTo(id);
}
JdbcHelper.ifPresent(id, criteria::andIdEqualTo);
JdbcHelper.ifPresent(ids, criteria::andIdIn);
Favorites favorites = new Favorites();
favorites.setDeleted(true);
favorites.setUpdateTime(new Date());
......
......@@ -64,4 +64,17 @@ public class ItemManagerImpl implements ItemManager {
int num = itemMapper.updateByExampleSelective(item, example);
return num > 0;
}
@Override
public int deleteUserItems(CoinRequestDto coinRequestDto) {
ItemExample example = new ItemExample();
ItemExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(coinRequestDto.getId(), criteria::andIdEqualTo);
JdbcHelper.ifPresent(coinRequestDto.getIds(), criteria::andIdIn);
criteria.andSourceTypeEqualTo(2);
Item item = new Item();
item.setUpdateTime(new Date());
item.setIsDeleted(true);
return itemMapper.updateByExampleSelective(item, example);
}
}
package com.wwdz.ch.db.manager.impl;
import com.wwdz.ch.db.dao.UsersItemsRelationMapper;
import com.wwdz.ch.db.domain.UsersItemsRelation;
import com.wwdz.ch.db.domain.UsersItemsRelationExample;
import com.wwdz.ch.db.manager.UsersItemsRelationManager;
import com.xxdxxs.db.component.JdbcHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class UsersItemsRelationManagerImpl implements UsersItemsRelationManager {
@Autowired
private UsersItemsRelationMapper usersItemsRelationMapper;
@Override
public List<UsersItemsRelation> listByUserIds(Long userId, List<Long> userIds) {
UsersItemsRelationExample example = new UsersItemsRelationExample();
UsersItemsRelationExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(userId, criteria::andUserIdEqualTo);
JdbcHelper.ifPresent(userIds, criteria::andUserIdIn);
return usersItemsRelationMapper.selectByExample(example);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wwdz.ch.db.dao.FavoritesCoinsRelationMapper">
<resultMap id="BaseResultMap" type="com.wwdz.ch.db.domain.FavoritesCoinsRelation">
<mapper namespace="com.wwdz.ch.db.dao.FavoritesItemsRelationMapper">
<resultMap id="BaseResultMap" type="com.wwdz.ch.db.domain.FavoritesItemsRelation">
<result column="favorites_id" jdbcType="BIGINT" property="favoritesId" />
<result column="coins_id" jdbcType="BIGINT" property="coinsId" />
<result column="item_id" jdbcType="BIGINT" property="itemId" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
......@@ -64,16 +65,16 @@
</where>
</sql>
<sql id="Base_Column_List">
favorites_id, coins_id
favorites_id, item_id, add_time
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.FavoritesCoinsRelationExample" resultMap="BaseResultMap">
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.FavoritesItemsRelationExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
'true' as QUERYID,
<include refid="Base_Column_List" />
from favorites_coins_relation
from favorites_items_relation
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
......@@ -99,10 +100,10 @@
</foreach>
</when>
<otherwise>
favorites_id, coins_id
favorites_id, item_id, add_time
</otherwise>
</choose>
from favorites_coins_relation
from favorites_items_relation
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -110,56 +111,67 @@
order by ${example.orderByClause}
</if>
</select>
<delete id="deleteByExample" parameterType="com.wwdz.ch.db.domain.FavoritesCoinsRelationExample">
delete from favorites_coins_relation
<delete id="deleteByExample" parameterType="com.wwdz.ch.db.domain.FavoritesItemsRelationExample">
delete from favorites_items_relation
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.wwdz.ch.db.domain.FavoritesCoinsRelation">
insert into favorites_coins_relation (favorites_id, coins_id)
values (#{favoritesId,jdbcType=BIGINT}, #{coinsId,jdbcType=BIGINT})
<insert id="insert" parameterType="com.wwdz.ch.db.domain.FavoritesItemsRelation">
insert into favorites_items_relation (favorites_id, item_id, add_time
)
values (#{favoritesId,jdbcType=BIGINT}, #{itemId,jdbcType=BIGINT}, #{addTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="batchInsert" parameterType="com.wwdz.ch.db.domain.FavoritesCoinsRelation">
insert into favorites_coins_relation (favorites_id, coins_id)
<insert id="batchInsert" parameterType="com.wwdz.ch.db.domain.FavoritesItemsRelation">
insert into favorites_coins_relation (favorites_id, item_id, add_time)
values
<foreach collection="list" item="item" separator=",">
(#{item.favoritesId,jdbcType=BIGINT}, #{item.coinsId,jdbcType=BIGINT})
(#{item.favoritesId,jdbcType=BIGINT}, #{item.itemId,jdbcType=BIGINT}, #{item.addTime,jdbcType=TIMESTAMP})
</foreach>
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.FavoritesCoinsRelation">
insert into favorites_coins_relation
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.FavoritesItemsRelation">
insert into favorites_items_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="favoritesId != null">
favorites_id,
</if>
<if test="coinsId != null">
coins_id,
<if test="itemId != null">
item_id,
</if>
<if test="addTime != null">
add_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="favoritesId != null">
#{favoritesId,jdbcType=BIGINT},
</if>
<if test="coinsId != null">
#{coinsId,jdbcType=BIGINT},
<if test="itemId != null">
#{itemId,jdbcType=BIGINT},
</if>
<if test="addTime != null">
#{addTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.wwdz.ch.db.domain.FavoritesCoinsRelationExample" resultType="java.lang.Long">
select count(*) from favorites_coins_relation
<select id="countByExample" parameterType="com.wwdz.ch.db.domain.FavoritesItemsRelationExample" resultType="java.lang.Long">
select count(*) from favorites_items_relation
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update favorites_coins_relation
update favorites_items_relation
<set>
<if test="record.favoritesId != null">
favorites_id = #{record.favoritesId,jdbcType=BIGINT},
</if>
<if test="record.coinsId != null">
coins_id = #{record.coinsId,jdbcType=BIGINT},
<if test="record.itemId != null">
item_id = #{record.itemId,jdbcType=BIGINT},
</if>
<if test="record.addTime != null">
add_time = #{record.addTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
......@@ -167,14 +179,15 @@
</if>
</update>
<update id="updateByExample" parameterType="map">
update favorites_coins_relation
update favorites_items_relation
set favorites_id = #{record.favoritesId,jdbcType=BIGINT},
coins_id = #{record.coinsId,jdbcType=BIGINT}
item_id = #{record.itemId,jdbcType=BIGINT},
add_time = #{record.addTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<select id="selectOneByExample" parameterType="com.wwdz.ch.db.domain.FavoritesCoinsRelationExample" resultMap="BaseResultMap">
<select id="selectOneByExample" parameterType="com.wwdz.ch.db.domain.FavoritesItemsRelationExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......@@ -183,7 +196,7 @@
select
'true' as QUERYID,
<include refid="Base_Column_List" />
from favorites_coins_relation
from favorites_items_relation
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
......@@ -207,10 +220,10 @@
</foreach>
</when>
<otherwise>
favorites_id, coins_id
favorites_id, item_id, add_time
</otherwise>
</choose>
from favorites_coins_relation
from favorites_items_relation
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......
......@@ -3,7 +3,7 @@
<mapper namespace="com.wwdz.ch.db.dao.FavoritesMapper">
<resultMap id="BaseResultMap" type="com.wwdz.ch.db.domain.Favorites">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="uid" jdbcType="BIGINT" property="uid" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
......@@ -72,7 +72,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `uid`, title, description, add_time, update_time, deleted
id, user_id, title, description, add_time, update_time, deleted
</sql>
<sql id="Blob_Column_List">
images
......@@ -121,13 +121,13 @@
distinct
</if>
<choose>
<when test="selective != null and selective.length > 0">
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, `uid`, title, description, add_time, update_time, deleted, images
id, user_id, title, description, add_time, update_time, deleted, images
</otherwise>
</choose>
from favorites
......@@ -176,13 +176,13 @@
-->
select
<choose>
<when test="selective != null and selective.length > 0">
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, `uid`, title, description, add_time, update_time, deleted, images
id, user_id, title, description, add_time, update_time, deleted, images
</otherwise>
</choose>
from favorites
......@@ -202,10 +202,10 @@
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into favorites (`uid`, title, description,
insert into favorites (user_id, title, description,
add_time, update_time, deleted,
images)
values (#{uid,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
values (#{userId,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT},
#{images,jdbcType=LONGVARCHAR})
</insert>
......@@ -215,8 +215,8 @@
</selectKey>
insert into favorites
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="uid != null">
`uid`,
<if test="userId != null">
user_id,
</if>
<if test="title != null">
title,
......@@ -238,8 +238,8 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="uid != null">
#{uid,jdbcType=BIGINT},
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="title != null">
#{title,jdbcType=VARCHAR},
......@@ -273,8 +273,8 @@
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.uid != null">
`uid` = #{record.uid,jdbcType=BIGINT},
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if test="record.title != null">
title = #{record.title,jdbcType=VARCHAR},
......@@ -302,7 +302,7 @@
<update id="updateByExampleWithBLOBs" parameterType="map">
update favorites
set id = #{record.id,jdbcType=BIGINT},
`uid` = #{record.uid,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
title = #{record.title,jdbcType=VARCHAR},
description = #{record.description,jdbcType=VARCHAR},
add_time = #{record.addTime,jdbcType=TIMESTAMP},
......@@ -316,7 +316,7 @@
<update id="updateByExample" parameterType="map">
update favorites
set id = #{record.id,jdbcType=BIGINT},
`uid` = #{record.uid,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
title = #{record.title,jdbcType=VARCHAR},
description = #{record.description,jdbcType=VARCHAR},
add_time = #{record.addTime,jdbcType=TIMESTAMP},
......@@ -329,8 +329,8 @@
<update id="updateByPrimaryKeySelective" parameterType="com.wwdz.ch.db.domain.Favorites">
update favorites
<set>
<if test="uid != null">
`uid` = #{uid,jdbcType=BIGINT},
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
......@@ -355,7 +355,7 @@
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.wwdz.ch.db.domain.Favorites">
update favorites
set `uid` = #{uid,jdbcType=BIGINT},
set user_id = #{userId,jdbcType=BIGINT},
title = #{title,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
add_time = #{addTime,jdbcType=TIMESTAMP},
......@@ -366,7 +366,7 @@
</update>
<update id="updateByPrimaryKey" parameterType="com.wwdz.ch.db.domain.Favorites">
update favorites
set `uid` = #{uid,jdbcType=BIGINT},
set user_id = #{userId,jdbcType=BIGINT},
title = #{title,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
add_time = #{addTime,jdbcType=TIMESTAMP},
......@@ -421,13 +421,13 @@
select
'true' as QUERYID,
<choose>
<when test="selective != null and selective.length > 0">
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, `uid`, title, description, add_time, update_time, deleted, images
id, user_id, title, description, add_time, update_time, deleted, images
</otherwise>
</choose>
from favorites
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wwdz.ch.db.dao.UsersItemsRelationMapper">
<resultMap id="BaseResultMap" type="com.wwdz.ch.db.domain.UsersItemsRelation">
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="item_id" jdbcType="BIGINT" property="itemId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
user_id, item_id
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.UsersItemsRelationExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
'true' as QUERYID,
<include refid="Base_Column_List" />
from users_items_relation
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExampleSelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
'true' as QUERYID,
<if test="example.distinct">
distinct
</if>
<choose>
<when test="selective != null and selective.length > 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
user_id, item_id
</otherwise>
</choose>
from users_items_relation
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
</select>
<delete id="deleteByExample" parameterType="com.wwdz.ch.db.domain.UsersItemsRelationExample">
delete from users_items_relation
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.wwdz.ch.db.domain.UsersItemsRelation">
insert into users_items_relation (user_id, item_id)
values (#{userId,jdbcType=BIGINT}, #{itemId,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.UsersItemsRelation">
insert into users_items_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">
user_id,
</if>
<if test="itemId != null">
item_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="itemId != null">
#{itemId,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.wwdz.ch.db.domain.UsersItemsRelationExample" resultType="java.lang.Long">
select count(*) from users_items_relation
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update users_items_relation
<set>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if test="record.itemId != null">
item_id = #{record.itemId,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update users_items_relation
set user_id = #{record.userId,jdbcType=BIGINT},
item_id = #{record.itemId,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<select id="selectOneByExample" parameterType="com.wwdz.ch.db.domain.UsersItemsRelationExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
'true' as QUERYID,
<include refid="Base_Column_List" />
from users_items_relation
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
limit 1
</select>
<select id="selectOneByExampleSelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
'true' as QUERYID,
<choose>
<when test="selective != null and selective.length > 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
user_id, item_id
</otherwise>
</choose>
from users_items_relation
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
limit 1
</select>
</mapper>
\ No newline at end of file
package com.wwdz.ch.wx.entity.request;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.util.List;
@Data
public class FavoritesItemRequestDto implements Entity {
private Long favoritesId;
private List<Long> itemIds;
private Long userId;
}
package com.wwdz.ch.wx.entity.request;
import com.github.pagehelper.Page;
import com.xxdxxs.entity.Entity;
import com.xxdxxs.support.Delete;
import com.xxdxxs.support.Insert;
import com.xxdxxs.support.Select;
......@@ -10,13 +11,10 @@ import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@Data
public class FavoritesRequestDto implements Serializable {
private static final long serialVersionUID = 1L;
public class FavoritesRequestDto implements Entity {
@NotNull(groups = {Update.class, Select.class}, message = "id不能为空")
private Long id;
......@@ -30,7 +28,7 @@ public class FavoritesRequestDto implements Serializable {
private String images;
@NotNull(groups = {Insert.class, Update.class, Page.class, Delete.class}, message = "用户id不能为空")
private Long uid;
private Long userId;
@NotNull(groups = Page.class, message = "当前页不能为空")
private Integer page;
......
package com.wwdz.ch.wx.service;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.entity.request.FavoritesItemRequestDto;
import com.wwdz.ch.wx.entity.request.FavoritesRequestDto;
public interface FavoritesService {
......@@ -15,4 +16,6 @@ public interface FavoritesService {
Result delete(FavoritesRequestDto dto);
Result batchDelete(FavoritesRequestDto dto);
Result removeItem(FavoritesItemRequestDto dto);
}
......@@ -2,9 +2,14 @@ package com.wwdz.ch.wx.service.impl;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.domain.Favorites;
import com.wwdz.ch.db.domain.FavoritesCoinsRelation;
import com.wwdz.ch.db.manager.FavoritesCoinsRelationManager;
import com.wwdz.ch.db.domain.FavoritesItemsRelation;
import com.wwdz.ch.db.domain.UsersItemsRelation;
import com.wwdz.ch.db.dto.request.CoinRequestDto;
import com.wwdz.ch.db.manager.FavoritesItemsRelationManager;
import com.wwdz.ch.db.manager.FavoritesManager;
import com.wwdz.ch.db.manager.ItemManager;
import com.wwdz.ch.db.manager.UsersItemsRelationManager;
import com.wwdz.ch.wx.entity.request.FavoritesItemRequestDto;
import com.wwdz.ch.wx.entity.request.FavoritesRequestDto;
import com.wwdz.ch.wx.service.FavoritesService;
import org.apache.commons.collections.CollectionUtils;
......@@ -18,6 +23,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
public class FavoritesServiceImpl implements FavoritesService {
......@@ -26,12 +32,16 @@ public class FavoritesServiceImpl implements FavoritesService {
@Autowired
private FavoritesManager favoritesManager;
@Autowired
private FavoritesCoinsRelationManager favoritesCoinsRelationManager;
private FavoritesItemsRelationManager favoritesItemsRelationManager;
@Autowired
private UsersItemsRelationManager usersItemsRelationManager;
@Autowired
private ItemManager itemManager;
@Override
public Result page(FavoritesRequestDto dto) {
try {
return Result.success(favoritesManager.pageByUid(dto.getUid(), dto.getPage(), dto.getSize()));
return Result.success(favoritesManager.pageByUserId(dto.getUserId(), dto.getPage(), dto.getSize()));
} catch (Exception e) {
logger.error("查询收藏册列表失败,原因:" + e.getMessage(), e);
return Result.failed(-1, "查询收藏册列表失败");
......@@ -43,12 +53,12 @@ public class FavoritesServiceImpl implements FavoritesService {
public Result add(FavoritesRequestDto dto) {
try {
// 判断收藏册标题是否已存在
if (favoritesManager.isExisted(null, dto.getUid(), dto.getTitle())) {
if (favoritesManager.isExisted(null, dto.getUserId(), dto.getTitle())) {
return Result.failed(-1, "收藏册的标题不能重复");
}
Favorites favorites = new Favorites();
favorites.setUid(dto.getUid());
favorites.setUserId(dto.getUserId());
favorites.setTitle(dto.getTitle());
favorites.setDescription(dto.getDescription());
favorites.setImages(dto.getImages());
......@@ -74,7 +84,7 @@ public class FavoritesServiceImpl implements FavoritesService {
return Result.failed("数据异常,记录不存在");
}
// 判断收藏册标题是否已存在
if (favoritesManager.isExisted(dto.getId(), dto.getUid(), dto.getTitle())) {
if (favoritesManager.isExisted(dto.getId(), dto.getUserId(), dto.getTitle())) {
return Result.failed("收藏册的标题不能重复");
}
......@@ -109,23 +119,18 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override
public Result delete(FavoritesRequestDto dto) {
try {
List<FavoritesCoinsRelation> list = favoritesCoinsRelationManager.listByFavoritesId(dto.getId(), null);
if (CollectionUtils.isNotEmpty(list)) {
return Result.failed("收藏册内有藏品,先移除藏品");
List<FavoritesItemsRelation> favoritesItemsList = favoritesItemsRelationManager.listByFavoritesId(dto.getId(), null);
if (CollectionUtils.isNotEmpty(favoritesItemsList)) {
return Result.failed("收藏册内有藏品,先移除藏品");
}
//TODO 删除该收藏册下用户创建的钱币
// 删除收藏册和钱币的关联
favoritesCoinsRelationManager.deleteByFavoritesId(dto.getId(), null);
// 删除收藏册
favoritesManager.delete(dto.getId(), null);
return Result.success();
} catch (Exception e) {
logger.error("批量删除收藏册失败,原因:" + e.getMessage(), e);
logger.error("删除收藏册失败,原因:" + e.getMessage(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Result.failed("批量删除收藏册失败");
return Result.failed("删除收藏册失败");
}
}
......@@ -133,11 +138,25 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override
public Result batchDelete(FavoritesRequestDto dto) {
try {
List<FavoritesCoinsRelation> list = favoritesCoinsRelationManager.listByFavoritesId(null, dto.getIds());
//TODO 删除该收藏册下用户创建的钱币
// 批量删除收藏册下用户创建的钱币
List<FavoritesItemsRelation> list = favoritesItemsRelationManager.listByFavoritesId(null, dto.getIds());
if (CollectionUtils.isNotEmpty(list)) {
List<Long> favoritesItemsIds = list.stream()
.map(FavoritesItemsRelation::getItemId).collect(Collectors.toList());
List<UsersItemsRelation> usersItemsList = usersItemsRelationManager.listByUserIds(dto.getUserId(), null);
if (CollectionUtils.isNotEmpty(usersItemsList)) {
List<Long> usersItemsIds = usersItemsList.stream()
.map(UsersItemsRelation::getItemId).collect(Collectors.toList());
List<Long> itemIds = favoritesItemsIds.stream()
.filter(usersItemsIds::contains).collect(Collectors.toList());
CoinRequestDto coinRequestDto = new CoinRequestDto();
coinRequestDto.setIds(itemIds);
itemManager.deleteUserItems(coinRequestDto);
}
}
// 删除收藏册和钱币的关联
favoritesCoinsRelationManager.deleteByFavoritesId(null, dto.getIds());
favoritesItemsRelationManager.deleteByFavoritesId(null, dto.getIds());
// 删除收藏册
favoritesManager.delete(null, dto.getIds());
......@@ -148,4 +167,30 @@ public class FavoritesServiceImpl implements FavoritesService {
return Result.failed("批量删除收藏册失败");
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public Result removeItem(FavoritesItemRequestDto dto) {
try {
// 批量删除收藏册下用户创建的钱币
List<UsersItemsRelation> usersItemsList = usersItemsRelationManager.listByUserIds(dto.getUserId(), null);
if (CollectionUtils.isNotEmpty(usersItemsList)) {
List<Long> usersItemsIds = usersItemsList.stream()
.map(UsersItemsRelation::getItemId).collect(Collectors.toList());
List<Long> itemIds = dto.getItemIds().stream()
.filter(usersItemsIds::contains).collect(Collectors.toList());
CoinRequestDto coinRequestDto = new CoinRequestDto();
coinRequestDto.setIds(itemIds);
itemManager.deleteUserItems(coinRequestDto);
}
// 删除收藏册和钱币的关联
favoritesItemsRelationManager.deleteByChosen(dto.getFavoritesId(), dto.getItemIds());
return Result.success();
} catch (Exception e) {
logger.info("收藏册取消收藏失败,原因:" + e.getMessage(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Result.failed("收藏册取消收藏失败");
}
}
}
......@@ -2,6 +2,7 @@ package com.wwdz.ch.wx.web;
import com.github.pagehelper.Page;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.entity.request.FavoritesItemRequestDto;
import com.wwdz.ch.wx.entity.request.FavoritesRequestDto;
import com.wwdz.ch.wx.service.FavoritesService;
import com.xxdxxs.support.Delete;
......@@ -63,4 +64,15 @@ public class WxFavoritesController {
}
return favoritesService.batchDelete(dto);
}
@PostMapping("/removeItem")
public Result removeItem(@RequestBody FavoritesItemRequestDto dto) {
if (Objects.isNull(dto.getFavoritesId())) {
return Result.failed("收藏册不能为空");
}
if (CollectionUtils.isEmpty(dto.getItemIds())) {
return Result.failed("请选择藏品");
}
return favoritesService.removeItem(dto);
}
}
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