Commit ae12606a authored by muhong's avatar muhong

修改 用户和商品收藏关联表表名

parent c3327171
package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.UsersItemsRelation;
import com.wwdz.ch.db.domain.UsersItemsRelationExample;
import com.wwdz.ch.db.domain.UserItemsRelation;
import com.wwdz.ch.db.domain.UserItemsRelationExample;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface UsersItemsRelationMapper {
long countByExample(UsersItemsRelationExample example);
public interface UserItemsRelationMapper {
long countByExample(UserItemsRelationExample example);
int deleteByExample(UsersItemsRelationExample example);
int deleteByExample(UserItemsRelationExample example);
int insert(UsersItemsRelation record);
int insert(UserItemsRelation record);
int insertSelective(UsersItemsRelation record);
int insertSelective(UserItemsRelation record);
/**
* This method was generated by MyBatis Generator.
......@@ -24,7 +24,7 @@ public interface UsersItemsRelationMapper {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UsersItemsRelation selectOneByExample(UsersItemsRelationExample example);
UserItemsRelation selectOneByExample(UserItemsRelationExample example);
/**
* This method was generated by MyBatis Generator.
......@@ -33,7 +33,7 @@ public interface UsersItemsRelationMapper {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UsersItemsRelation selectOneByExampleSelective(@Param("example") UsersItemsRelationExample example, @Param("selective") UsersItemsRelation.Column ... selective);
UserItemsRelation selectOneByExampleSelective(@Param("example") UserItemsRelationExample example, @Param("selective") UserItemsRelation.Column ... selective);
/**
* This method was generated by MyBatis Generator.
......@@ -42,11 +42,11 @@ public interface UsersItemsRelationMapper {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<UsersItemsRelation> selectByExampleSelective(@Param("example") UsersItemsRelationExample example, @Param("selective") UsersItemsRelation.Column ... selective);
List<UserItemsRelation> selectByExampleSelective(@Param("example") UserItemsRelationExample example, @Param("selective") UserItemsRelation.Column ... selective);
List<UsersItemsRelation> selectByExample(UsersItemsRelationExample example);
List<UserItemsRelation> selectByExample(UserItemsRelationExample example);
int updateByExampleSelective(@Param("record") UsersItemsRelation record, @Param("example") UsersItemsRelationExample example);
int updateByExampleSelective(@Param("record") UserItemsRelation record, @Param("example") UserItemsRelationExample example);
int updateByExample(@Param("record") UsersItemsRelation record, @Param("example") UsersItemsRelationExample example);
int updateByExample(@Param("record") UserItemsRelation record, @Param("example") UserItemsRelationExample example);
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ import lombok.Data;
* @date 2023/07/21
*/
@Data
public class UsersItemsRelation implements Serializable {
public class UserItemsRelation implements Serializable {
/**
* 用户id
*/
......@@ -47,7 +47,7 @@ public class UsersItemsRelation implements Serializable {
if (getClass() != that.getClass()) {
return false;
}
UsersItemsRelation other = (UsersItemsRelation) that;
UserItemsRelation other = (UserItemsRelation) that;
return (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getItemId() == null ? other.getItemId() == null : this.getItemId().equals(other.getItemId()));
}
......
......@@ -3,14 +3,14 @@ package com.wwdz.ch.db.domain;
import java.util.ArrayList;
import java.util.List;
public class UsersItemsRelationExample {
public class UserItemsRelationExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public UsersItemsRelationExample() {
public UserItemsRelationExample() {
oredCriteria = new ArrayList<Criteria>();
}
......@@ -51,7 +51,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public UsersItemsRelationExample orderBy(String orderByClause) {
public UserItemsRelationExample orderBy(String orderByClause) {
this.setOrderByClause(orderByClause);
return this;
}
......@@ -63,7 +63,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public UsersItemsRelationExample orderBy(String ... orderByClauses) {
public UserItemsRelationExample orderBy(String ... orderByClauses) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < orderByClauses.length; i++) {
sb.append(orderByClauses[i]);
......@@ -102,7 +102,7 @@ public class UsersItemsRelationExample {
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static Criteria newAndCreateCriteria() {
UsersItemsRelationExample example = new UsersItemsRelationExample();
UserItemsRelationExample example = new UserItemsRelationExample();
return example.createCriteria();
}
......@@ -169,7 +169,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserIdEqualToColumn(UsersItemsRelation.Column column) {
public Criteria andUserIdEqualToColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("user_id = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -186,7 +186,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserIdNotEqualToColumn(UsersItemsRelation.Column column) {
public Criteria andUserIdNotEqualToColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("user_id <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -203,7 +203,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserIdGreaterThanColumn(UsersItemsRelation.Column column) {
public Criteria andUserIdGreaterThanColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("user_id > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -220,7 +220,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserIdGreaterThanOrEqualToColumn(UsersItemsRelation.Column column) {
public Criteria andUserIdGreaterThanOrEqualToColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("user_id >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -237,7 +237,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserIdLessThanColumn(UsersItemsRelation.Column column) {
public Criteria andUserIdLessThanColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("user_id < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -254,7 +254,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserIdLessThanOrEqualToColumn(UsersItemsRelation.Column column) {
public Criteria andUserIdLessThanOrEqualToColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("user_id <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -301,7 +301,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andItemIdEqualToColumn(UsersItemsRelation.Column column) {
public Criteria andItemIdEqualToColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("item_id = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -318,7 +318,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andItemIdNotEqualToColumn(UsersItemsRelation.Column column) {
public Criteria andItemIdNotEqualToColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("item_id <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -335,7 +335,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andItemIdGreaterThanColumn(UsersItemsRelation.Column column) {
public Criteria andItemIdGreaterThanColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("item_id > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -352,7 +352,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andItemIdGreaterThanOrEqualToColumn(UsersItemsRelation.Column column) {
public Criteria andItemIdGreaterThanOrEqualToColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("item_id >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -369,7 +369,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andItemIdLessThanColumn(UsersItemsRelation.Column column) {
public Criteria andItemIdLessThanColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("item_id < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -386,7 +386,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andItemIdLessThanOrEqualToColumn(UsersItemsRelation.Column column) {
public Criteria andItemIdLessThanOrEqualToColumn(UserItemsRelation.Column column) {
addCriterion(new StringBuilder("item_id <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
......@@ -420,7 +420,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private UsersItemsRelationExample example;
private UserItemsRelationExample example;
/**
* This method was generated by MyBatis Generator.
......@@ -429,7 +429,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
protected Criteria(UsersItemsRelationExample example) {
protected Criteria(UserItemsRelationExample example) {
super();
this.example = example;
}
......@@ -441,7 +441,7 @@ public class UsersItemsRelationExample {
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public UsersItemsRelationExample example() {
public UserItemsRelationExample example() {
return this.example;
}
......
package com.wwdz.ch.db.manager;
import com.wwdz.ch.db.domain.UserItemsRelation;
import java.util.List;
public interface UserItemsRelationManager {
List<UserItemsRelation> listByUserIds(Long userId, List<Long> userIds);
}
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.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.wwdz.ch.db.dao.UserItemsRelationMapper;
import com.wwdz.ch.db.domain.UserItemsRelation;
import com.wwdz.ch.db.domain.UserItemsRelationExample;
import com.wwdz.ch.db.manager.UserItemsRelationManager;
import com.xxdxxs.db.component.JdbcHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
......@@ -11,14 +11,14 @@ import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class UsersItemsRelationManagerImpl implements UsersItemsRelationManager {
public class UserItemsRelationManagerImpl implements UserItemsRelationManager {
@Autowired
private UsersItemsRelationMapper usersItemsRelationMapper;
private UserItemsRelationMapper usersItemsRelationMapper;
@Override
public List<UsersItemsRelation> listByUserIds(Long userId, List<Long> userIds) {
UsersItemsRelationExample example = new UsersItemsRelationExample();
UsersItemsRelationExample.Criteria criteria = example.createCriteria();
public List<UserItemsRelation> listByUserIds(Long userId, List<Long> userIds) {
UserItemsRelationExample example = new UserItemsRelationExample();
UserItemsRelationExample.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.UsersItemsRelationMapper">
<resultMap id="BaseResultMap" type="com.wwdz.ch.db.domain.UsersItemsRelation">
<mapper namespace="com.wwdz.ch.db.dao.UserItemsRelationMapper">
<resultMap id="BaseResultMap" type="com.wwdz.ch.db.domain.UserItemsRelation">
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="item_id" jdbcType="BIGINT" property="itemId" />
</resultMap>
......@@ -66,14 +66,14 @@
<sql id="Base_Column_List">
user_id, item_id
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.UsersItemsRelationExample" resultMap="BaseResultMap">
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.UserItemsRelationExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
'true' as QUERYID,
<include refid="Base_Column_List" />
from users_items_relation
from user_items_relation
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
......@@ -102,7 +102,7 @@
user_id, item_id
</otherwise>
</choose>
from users_items_relation
from user_items_relation
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -110,18 +110,18 @@
order by ${example.orderByClause}
</if>
</select>
<delete id="deleteByExample" parameterType="com.wwdz.ch.db.domain.UsersItemsRelationExample">
delete from users_items_relation
<delete id="deleteByExample" parameterType="com.wwdz.ch.db.domain.UserItemsRelationExample">
delete from user_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)
<insert id="insert" parameterType="com.wwdz.ch.db.domain.UserItemsRelation">
insert into user_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
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.UserItemsRelation">
insert into user_items_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">
user_id,
......@@ -139,14 +139,14 @@
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.wwdz.ch.db.domain.UsersItemsRelationExample" resultType="java.lang.Long">
select count(*) from users_items_relation
<select id="countByExample" parameterType="com.wwdz.ch.db.domain.UserItemsRelationExample" resultType="java.lang.Long">
select count(*) from user_items_relation
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update users_items_relation
update user_items_relation
<set>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
......@@ -160,14 +160,14 @@
</if>
</update>
<update id="updateByExample" parameterType="map">
update users_items_relation
update user_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">
<select id="selectOneByExample" parameterType="com.wwdz.ch.db.domain.UserItemsRelationExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......@@ -176,7 +176,7 @@
select
'true' as QUERYID,
<include refid="Base_Column_List" />
from users_items_relation
from user_items_relation
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
......@@ -203,7 +203,7 @@
user_id, item_id
</otherwise>
</choose>
from users_items_relation
from user_items_relation
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......
......@@ -3,12 +3,12 @@ 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.FavoritesItemsRelation;
import com.wwdz.ch.db.domain.UsersItemsRelation;
import com.wwdz.ch.db.domain.UserItemsRelation;
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.db.manager.UserItemsRelationManager;
import com.wwdz.ch.wx.entity.request.FavoritesItemRequestDto;
import com.wwdz.ch.wx.entity.request.FavoritesRequestDto;
import com.wwdz.ch.wx.service.FavoritesService;
......@@ -34,7 +34,7 @@ public class FavoritesServiceImpl implements FavoritesService {
@Autowired
private FavoritesItemsRelationManager favoritesItemsRelationManager;
@Autowired
private UsersItemsRelationManager usersItemsRelationManager;
private UserItemsRelationManager userItemsRelationManager;
@Autowired
private ItemManager itemManager;
......@@ -143,10 +143,10 @@ public class FavoritesServiceImpl implements FavoritesService {
if (CollectionUtils.isNotEmpty(list)) {
List<Long> favoritesItemsIds = list.stream()
.map(FavoritesItemsRelation::getItemId).collect(Collectors.toList());
List<UsersItemsRelation> usersItemsList = usersItemsRelationManager.listByUserIds(dto.getUserId(), null);
List<UserItemsRelation> usersItemsList = userItemsRelationManager.listByUserIds(dto.getUserId(), null);
if (CollectionUtils.isNotEmpty(usersItemsList)) {
List<Long> usersItemsIds = usersItemsList.stream()
.map(UsersItemsRelation::getItemId).collect(Collectors.toList());
.map(UserItemsRelation::getItemId).collect(Collectors.toList());
List<Long> itemIds = favoritesItemsIds.stream()
.filter(usersItemsIds::contains).collect(Collectors.toList());
CoinRequestDto coinRequestDto = new CoinRequestDto();
......@@ -173,10 +173,10 @@ public class FavoritesServiceImpl implements FavoritesService {
public Result removeItem(FavoritesItemRequestDto dto) {
try {
// 批量删除收藏册下用户创建的钱币
List<UsersItemsRelation> usersItemsList = usersItemsRelationManager.listByUserIds(dto.getUserId(), null);
List<UserItemsRelation> usersItemsList = userItemsRelationManager.listByUserIds(dto.getUserId(), null);
if (CollectionUtils.isNotEmpty(usersItemsList)) {
List<Long> usersItemsIds = usersItemsList.stream()
.map(UsersItemsRelation::getItemId).collect(Collectors.toList());
.map(UserItemsRelation::getItemId).collect(Collectors.toList());
List<Long> itemIds = dto.getItemIds().stream()
.filter(usersItemsIds::contains).collect(Collectors.toList());
CoinRequestDto coinRequestDto = new CoinRequestDto();
......
......@@ -9,6 +9,7 @@ import com.xxdxxs.support.Delete;
import com.xxdxxs.support.Insert;
import com.xxdxxs.support.Select;
import com.xxdxxs.support.Update;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -29,26 +30,31 @@ public class WxFavoritesController {
@Autowired
private FavoritesService favoritesService;
@ApiOperation(value = "分页查询")
@PostMapping("/page")
public Result page(@RequestBody @Validated(Page.class)FavoritesRequestDto dto) {
return favoritesService.page(dto);
}
@ApiOperation(value = "新增")
@PostMapping("/add")
public Result add(@RequestBody @Validated(Insert.class)FavoritesRequestDto dto) {
return favoritesService.add(dto);
}
@ApiOperation(value = "修改")
@PostMapping("/update")
public Result update(@RequestBody @Validated(Update.class)FavoritesRequestDto dto) {
return favoritesService.update(dto);
}
@ApiOperation(value = "详情")
@PostMapping("/info")
public Result info(@RequestBody @Validated(Select.class) FavoritesRequestDto dto) {
return favoritesService.info(dto);
}
@ApiOperation(value = "单个删除")
@PostMapping("/delete")
public Result delete(@RequestBody @Validated(Delete.class) FavoritesRequestDto dto) {
if (Objects.isNull(dto.getId())) {
......@@ -57,6 +63,7 @@ public class WxFavoritesController {
return favoritesService.delete(dto);
}
@ApiOperation(value = "批量删除")
@PostMapping("/batchDelete")
public Result batchDelete(@RequestBody @Validated(Delete.class) FavoritesRequestDto dto) {
if (CollectionUtils.isEmpty(dto.getIds())) {
......@@ -65,6 +72,7 @@ public class WxFavoritesController {
return favoritesService.batchDelete(dto);
}
@ApiOperation(value = "移除藏品")
@PostMapping("/removeItem")
public Result removeItem(@RequestBody FavoritesItemRequestDto dto) {
if (Objects.isNull(dto.getFavoritesId())) {
......
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