Commit 508916b0 authored by muhong's avatar muhong

新增修改 小程序相关接口

parent b0aeefd2
...@@ -27,4 +27,6 @@ public interface ItemManager { ...@@ -27,4 +27,6 @@ public interface ItemManager {
long countByCid(Integer cid); long countByCid(Integer cid);
int insert(Item item); int insert(Item item);
int update(Item item);
} }
package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.User;
public interface UserDao {
User queryByOid(String openId);
User queryByMobile(String mobile);
User queryById(Long id);
int insert(User user);
int updateById(User user);
boolean isExistedByMobile(String beforeMobile, String afterMobile);
}
...@@ -119,4 +119,9 @@ public class ItemManagerImpl implements ItemManager { ...@@ -119,4 +119,9 @@ public class ItemManagerImpl implements ItemManager {
public int insert(Item item) { public int insert(Item item) {
return itemMapper.insert(item); return itemMapper.insert(item);
} }
@Override
public int update(Item item) {
return itemMapper.updateByPrimaryKeySelective(item);
}
} }
package com.wwdz.ch.db.dao.impl;
import com.wwdz.ch.db.dao.UserDao;
import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.db.domain.UserExample;
import com.wwdz.ch.db.mapper.UserMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.Date;
@Repository
public class UserDaoImpl implements UserDao {
@Autowired
private UserMapper userMapper;
@Override
public User queryByOid(String openId) {
UserExample example = new UserExample();
example.or().andWeixinOpenidEqualTo(openId).andDeletedEqualTo(false);
return userMapper.selectOneByExample(example);
}
@Override
public User queryByMobile(String mobile) {
UserExample example = new UserExample();
example.or().andMobileEqualTo(mobile).andDeletedEqualTo(false);
return userMapper.selectOneByExample(example);
}
@Override
public User queryById(Long id) {
UserExample example = new UserExample();
example.or().andIdEqualTo(id).andDeletedEqualTo(false);
return userMapper.selectOneByExample(example);
}
@Override
public int insert(User user) {
return userMapper.insert(user);
}
@Override
public int updateById(User user) {
user.setUpdateTime(new Date());
return userMapper.updateByPrimaryKeySelective(user);
}
@Override
public boolean isExistedByMobile(String beforeMobile, String afterMobile) {
UserExample example = new UserExample();
UserExample.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(beforeMobile)) {
criteria.andMobileNotEqualTo(beforeMobile);
}
criteria.andMobileEqualTo(afterMobile);
criteria.andDeletedEqualTo(false);
return userMapper.countByExample(example) > 0;
}
}
...@@ -2,55 +2,24 @@ package com.wwdz.ch.db.mapper; ...@@ -2,55 +2,24 @@ package com.wwdz.ch.db.mapper;
import com.wwdz.ch.db.domain.Footprint; import com.wwdz.ch.db.domain.Footprint;
import com.wwdz.ch.db.domain.FootprintExample; import com.wwdz.ch.db.domain.FootprintExample;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface FootprintMapper { public interface FootprintMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint
*
* @mbg.generated
*/
long countByExample(FootprintExample example); long countByExample(FootprintExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint
*
* @mbg.generated
*/
int deleteByExample(FootprintExample example); int deleteByExample(FootprintExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint
*
* @mbg.generated
*/
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint
*
* @mbg.generated
*/
int insert(Footprint record); int insert(Footprint record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint
*
* @mbg.generated
*/
int insertSelective(Footprint record); int insertSelective(Footprint record);
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint * This method corresponds to the database table footprint
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
...@@ -59,7 +28,7 @@ public interface FootprintMapper { ...@@ -59,7 +28,7 @@ public interface FootprintMapper {
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint * This method corresponds to the database table footprint
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
...@@ -68,82 +37,46 @@ public interface FootprintMapper { ...@@ -68,82 +37,46 @@ public interface FootprintMapper {
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint * This method corresponds to the database table footprint
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
*/ */
List<Footprint> selectByExampleSelective(@Param("example") FootprintExample example, @Param("selective") Footprint.Column ... selective); List<Footprint> selectByExampleSelective(@Param("example") FootprintExample example, @Param("selective") Footprint.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint
*
* @mbg.generated
*/
List<Footprint> selectByExample(FootprintExample example); List<Footprint> selectByExample(FootprintExample example);
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint * This method corresponds to the database table footprint
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
*/ */
Footprint selectByPrimaryKeySelective(@Param("id") Long id, @Param("selective") Footprint.Column ... selective); Footprint selectByPrimaryKeySelective(@Param("id") Long id, @Param("selective") Footprint.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint
*
* @mbg.generated
*/
Footprint selectByPrimaryKey(Long id); Footprint selectByPrimaryKey(Long id);
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint * This method corresponds to the database table footprint
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
*/ */
Footprint selectByPrimaryKeyWithLogicalDelete(@Param("id") Long id, @Param("andLogicalDeleted") boolean andLogicalDeleted); Footprint selectByPrimaryKeyWithLogicalDelete(@Param("id") Long id, @Param("andLogicalDeleted") boolean andLogicalDeleted);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") Footprint record, @Param("example") FootprintExample example); int updateByExampleSelective(@Param("record") Footprint record, @Param("example") FootprintExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint
*
* @mbg.generated
*/
int updateByExample(@Param("record") Footprint record, @Param("example") FootprintExample example); int updateByExample(@Param("record") Footprint record, @Param("example") FootprintExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(Footprint record); int updateByPrimaryKeySelective(Footprint record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint
*
* @mbg.generated
*/
int updateByPrimaryKey(Footprint record); int updateByPrimaryKey(Footprint record);
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint * This method corresponds to the database table footprint
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
...@@ -152,7 +85,7 @@ public interface FootprintMapper { ...@@ -152,7 +85,7 @@ public interface FootprintMapper {
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_footprint * This method corresponds to the database table footprint
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
......
...@@ -2,55 +2,24 @@ package com.wwdz.ch.db.mapper; ...@@ -2,55 +2,24 @@ package com.wwdz.ch.db.mapper;
import com.wwdz.ch.db.domain.User; import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.db.domain.UserExample; import com.wwdz.ch.db.domain.UserExample;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface UserMapper { public interface UserMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user
*
* @mbg.generated
*/
long countByExample(UserExample example); long countByExample(UserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user
*
* @mbg.generated
*/
int deleteByExample(UserExample example); int deleteByExample(UserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user
*
* @mbg.generated
*/
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user
*
* @mbg.generated
*/
int insert(User record); int insert(User record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user
*
* @mbg.generated
*/
int insertSelective(User record); int insertSelective(User record);
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user * This method corresponds to the database table user
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
...@@ -59,7 +28,7 @@ public interface UserMapper { ...@@ -59,7 +28,7 @@ public interface UserMapper {
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user * This method corresponds to the database table user
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
...@@ -68,82 +37,46 @@ public interface UserMapper { ...@@ -68,82 +37,46 @@ public interface UserMapper {
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user * This method corresponds to the database table user
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
*/ */
List<User> selectByExampleSelective(@Param("example") UserExample example, @Param("selective") User.Column ... selective); List<User> selectByExampleSelective(@Param("example") UserExample example, @Param("selective") User.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user
*
* @mbg.generated
*/
List<User> selectByExample(UserExample example); List<User> selectByExample(UserExample example);
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user * This method corresponds to the database table user
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
*/ */
User selectByPrimaryKeySelective(@Param("id") Long id, @Param("selective") User.Column ... selective); User selectByPrimaryKeySelective(@Param("id") Long id, @Param("selective") User.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user
*
* @mbg.generated
*/
User selectByPrimaryKey(Long id); User selectByPrimaryKey(Long id);
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user * This method corresponds to the database table user
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
*/ */
User selectByPrimaryKeyWithLogicalDelete(@Param("id") Long id, @Param("andLogicalDeleted") boolean andLogicalDeleted); User selectByPrimaryKeyWithLogicalDelete(@Param("id") Long id, @Param("andLogicalDeleted") boolean andLogicalDeleted);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example); int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user
*
* @mbg.generated
*/
int updateByExample(@Param("record") User record, @Param("example") UserExample example); int updateByExample(@Param("record") User record, @Param("example") UserExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(User record); int updateByPrimaryKeySelective(User record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user
*
* @mbg.generated
*/
int updateByPrimaryKey(User record); int updateByPrimaryKey(User record);
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user * This method corresponds to the database table user
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
...@@ -152,7 +85,7 @@ public interface UserMapper { ...@@ -152,7 +85,7 @@ public interface UserMapper {
/** /**
* This method was generated by MyBatis Generator. * This method was generated by MyBatis Generator.
* This method corresponds to the database table dts_user * This method corresponds to the database table user
* *
* @mbg.generated * @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin * @project https://github.com/itfsw/mybatis-generator-plugin
......
package com.wwdz.ch.db.service; package com.wwdz.ch.db.service;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.wwdz.ch.db.mapper.FootprintMapper;
import com.wwdz.ch.db.domain.Footprint; import com.wwdz.ch.db.domain.Footprint;
import com.wwdz.ch.db.domain.FootprintExample; import com.wwdz.ch.db.domain.FootprintExample;
import com.wwdz.ch.db.mapper.FootprintMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.util.Date;
import java.util.List; import java.util.List;
@Service @Service
...@@ -34,8 +33,8 @@ public class DtsFootprintService { ...@@ -34,8 +33,8 @@ public class DtsFootprintService {
} }
public void add(Footprint footprint) { public void add(Footprint footprint) {
footprint.setAddTime(LocalDateTime.now()); footprint.setAddTime(new Date());
footprint.setUpdateTime(LocalDateTime.now()); footprint.setUpdateTime(new Date());
footprintMapper.insertSelective(footprint); footprintMapper.insertSelective(footprint);
} }
...@@ -48,7 +47,7 @@ public class DtsFootprintService { ...@@ -48,7 +47,7 @@ public class DtsFootprintService {
criteria.andUserIdEqualTo(Long.valueOf(userId)); criteria.andUserIdEqualTo(Long.valueOf(userId));
} }
if (!StringUtils.isEmpty(coinsId)) { if (!StringUtils.isEmpty(coinsId)) {
criteria.andCoinsIdEqualTo(Long.valueOf(coinsId)); criteria.andItemIdEqualTo(Long.valueOf(coinsId));
} }
criteria.andDeletedEqualTo(false); criteria.andDeletedEqualTo(false);
......
package com.wwdz.ch.db.service; package com.wwdz.ch.db.service;
import java.time.LocalDateTime;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.wwdz.ch.db.bean.DayStatis; import com.wwdz.ch.db.bean.DayStatis;
import com.wwdz.ch.db.mapper.UserAccountObsoleteMapper;
import com.wwdz.ch.db.mapper.UserMapper;
import com.wwdz.ch.db.mapper.ex.StatMapper;
import com.wwdz.ch.db.domain.User; import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.db.domain.UserExample; import com.wwdz.ch.db.domain.UserExample;
import com.wwdz.ch.db.domain.UserVo; import com.wwdz.ch.db.domain.UserVo;
import com.wwdz.ch.db.mapper.UserAccountObsoleteMapper;
import com.wwdz.ch.db.mapper.UserMapper;
import com.wwdz.ch.db.mapper.ex.StatMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service @Service
public class DtsUserService { public class DtsUserService {
...@@ -48,13 +46,13 @@ public class DtsUserService { ...@@ -48,13 +46,13 @@ public class DtsUserService {
} }
public void add(User user) { public void add(User user) {
user.setAddTime(LocalDateTime.now()); user.setAddTime(new Date());
user.setUpdateTime(LocalDateTime.now()); user.setUpdateTime(new Date());
userMapper.insertSelective(user); userMapper.insertSelective(user);
} }
public int updateById(User user) { public int updateById(User user) {
user.setUpdateTime(LocalDateTime.now()); user.setUpdateTime(new Date());
return userMapper.updateByPrimaryKeySelective(user); return userMapper.updateByPrimaryKeySelective(user);
} }
......
...@@ -2,22 +2,14 @@ ...@@ -2,22 +2,14 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wwdz.ch.db.mapper.FootprintMapper"> <mapper namespace="com.wwdz.ch.db.mapper.FootprintMapper">
<resultMap id="BaseResultMap" type="com.wwdz.ch.db.domain.Footprint"> <resultMap id="BaseResultMap" type="com.wwdz.ch.db.domain.Footprint">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="BIGINT" property="userId" /> <result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="coins_id" jdbcType="BIGINT" property="coinsId" /> <result column="item_id" jdbcType="BIGINT" property="itemId" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" /> <result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="deleted" jdbcType="BIT" property="deleted" /> <result column="deleted" jdbcType="BIT" property="deleted" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where> <where>
<foreach collection="oredCriteria" item="criteria" separator="or"> <foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid"> <if test="criteria.valid">
...@@ -47,10 +39,6 @@ ...@@ -47,10 +39,6 @@
</where> </where>
</sql> </sql>
<sql id="Update_By_Example_Where_Clause"> <sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where> <where>
<foreach collection="example.oredCriteria" item="criteria" separator="or"> <foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid"> <if test="criteria.valid">
...@@ -80,21 +68,14 @@ ...@@ -80,21 +68,14 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!-- id, user_id, item_id, add_time, update_time, deleted
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, user_id, coins_id, add_time, update_time, deleted
</sql> </sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.FootprintExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.wwdz.ch.db.domain.FootprintExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select select
<if test="distinct"> <if test="distinct">
distinct distinct
</if> </if>
'true' as QUERYID,
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from footprint from footprint
<if test="_parameter != null"> <if test="_parameter != null">
...@@ -111,6 +92,7 @@ ...@@ -111,6 +92,7 @@
@project https://github.com/itfsw/mybatis-generator-plugin @project https://github.com/itfsw/mybatis-generator-plugin
--> -->
select select
'true' as QUERYID,
<if test="example.distinct"> <if test="example.distinct">
distinct distinct
</if> </if>
...@@ -121,7 +103,7 @@ ...@@ -121,7 +103,7 @@
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, user_id, coins_id, add_time, update_time, deleted id, user_id, item_id, add_time, update_time, deleted
</otherwise> </otherwise>
</choose> </choose>
from footprint from footprint
...@@ -133,10 +115,6 @@ ...@@ -133,10 +115,6 @@
</if> </if>
</select> </select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from footprint from footprint
...@@ -148,10 +126,6 @@ ...@@ -148,10 +126,6 @@
This element is automatically generated by MyBatis Generator, do not modify. This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin @project https://github.com/itfsw/mybatis-generator-plugin
--> -->
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from footprint from footprint
...@@ -180,48 +154,32 @@ ...@@ -180,48 +154,32 @@
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, user_id, coins_id, add_time, update_time, deleted id, user_id, item_id, add_time, update_time, deleted
</otherwise> </otherwise>
</choose> </choose>
from footprint from footprint
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from footprint delete from footprint
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</delete> </delete>
<delete id="deleteByExample" parameterType="com.wwdz.ch.db.domain.FootprintExample"> <delete id="deleteByExample" parameterType="com.wwdz.ch.db.domain.FootprintExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from footprint delete from footprint
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="com.wwdz.ch.db.domain.Footprint"> <insert id="insert" parameterType="com.wwdz.ch.db.domain.Footprint">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID() SELECT LAST_INSERT_ID()
</selectKey> </selectKey>
insert into footprint (user_id, coins_id, add_time, insert into footprint (user_id, item_id, add_time,
update_time, deleted) update_time, deleted)
values (#{userId,jdbcType=BIGINT}, #{coinsId,jdbcType=BIGINT}, #{addTime,jdbcType=TIMESTAMP}, values (#{userId,jdbcType=BIGINT}, #{itemId,jdbcType=BIGINT}, #{addTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT}) #{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT})
</insert> </insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.Footprint"> <insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.Footprint">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID() SELECT LAST_INSERT_ID()
</selectKey> </selectKey>
...@@ -230,8 +188,8 @@ ...@@ -230,8 +188,8 @@
<if test="userId != null"> <if test="userId != null">
user_id, user_id,
</if> </if>
<if test="coinsId != null"> <if test="itemId != null">
coins_id, item_id,
</if> </if>
<if test="addTime != null"> <if test="addTime != null">
add_time, add_time,
...@@ -247,8 +205,8 @@ ...@@ -247,8 +205,8 @@
<if test="userId != null"> <if test="userId != null">
#{userId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
</if> </if>
<if test="coinsId != null"> <if test="itemId != null">
#{coinsId,jdbcType=BIGINT}, #{itemId,jdbcType=BIGINT},
</if> </if>
<if test="addTime != null"> <if test="addTime != null">
#{addTime,jdbcType=TIMESTAMP}, #{addTime,jdbcType=TIMESTAMP},
...@@ -262,20 +220,12 @@ ...@@ -262,20 +220,12 @@
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.wwdz.ch.db.domain.FootprintExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.wwdz.ch.db.domain.FootprintExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from footprint select count(*) from footprint
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
</select> </select>
<update id="updateByExampleSelective" parameterType="map"> <update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update footprint update footprint
<set> <set>
<if test="record.id != null"> <if test="record.id != null">
...@@ -284,8 +234,8 @@ ...@@ -284,8 +234,8 @@
<if test="record.userId != null"> <if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT}, user_id = #{record.userId,jdbcType=BIGINT},
</if> </if>
<if test="record.coinsId != null"> <if test="record.itemId != null">
coins_id = #{record.coinsId,jdbcType=BIGINT}, item_id = #{record.itemId,jdbcType=BIGINT},
</if> </if>
<if test="record.addTime != null"> <if test="record.addTime != null">
add_time = #{record.addTime,jdbcType=TIMESTAMP}, add_time = #{record.addTime,jdbcType=TIMESTAMP},
...@@ -302,14 +252,10 @@ ...@@ -302,14 +252,10 @@
</if> </if>
</update> </update>
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update footprint update footprint
set id = #{record.id,jdbcType=BIGINT}, set id = #{record.id,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT}, user_id = #{record.userId,jdbcType=BIGINT},
coins_id = #{record.coinsId,jdbcType=BIGINT}, item_id = #{record.itemId,jdbcType=BIGINT},
add_time = #{record.addTime,jdbcType=TIMESTAMP}, add_time = #{record.addTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP},
deleted = #{record.deleted,jdbcType=BIT} deleted = #{record.deleted,jdbcType=BIT}
...@@ -318,17 +264,13 @@ ...@@ -318,17 +264,13 @@
</if> </if>
</update> </update>
<update id="updateByPrimaryKeySelective" parameterType="com.wwdz.ch.db.domain.Footprint"> <update id="updateByPrimaryKeySelective" parameterType="com.wwdz.ch.db.domain.Footprint">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update footprint update footprint
<set> <set>
<if test="userId != null"> <if test="userId != null">
user_id = #{userId,jdbcType=BIGINT}, user_id = #{userId,jdbcType=BIGINT},
</if> </if>
<if test="coinsId != null"> <if test="itemId != null">
coins_id = #{coinsId,jdbcType=BIGINT}, item_id = #{itemId,jdbcType=BIGINT},
</if> </if>
<if test="addTime != null"> <if test="addTime != null">
add_time = #{addTime,jdbcType=TIMESTAMP}, add_time = #{addTime,jdbcType=TIMESTAMP},
...@@ -343,13 +285,9 @@ ...@@ -343,13 +285,9 @@
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<update id="updateByPrimaryKey" parameterType="com.wwdz.ch.db.domain.Footprint"> <update id="updateByPrimaryKey" parameterType="com.wwdz.ch.db.domain.Footprint">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update footprint update footprint
set user_id = #{userId,jdbcType=BIGINT}, set user_id = #{userId,jdbcType=BIGINT},
coins_id = #{coinsId,jdbcType=BIGINT}, item_id = #{itemId,jdbcType=BIGINT},
add_time = #{addTime,jdbcType=TIMESTAMP}, add_time = #{addTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
deleted = #{deleted,jdbcType=BIT} deleted = #{deleted,jdbcType=BIT}
...@@ -362,6 +300,7 @@ ...@@ -362,6 +300,7 @@
@project https://github.com/itfsw/mybatis-generator-plugin @project https://github.com/itfsw/mybatis-generator-plugin
--> -->
select select
'true' as QUERYID,
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from footprint from footprint
<if test="_parameter != null"> <if test="_parameter != null">
...@@ -379,6 +318,7 @@ ...@@ -379,6 +318,7 @@
@project https://github.com/itfsw/mybatis-generator-plugin @project https://github.com/itfsw/mybatis-generator-plugin
--> -->
select select
'true' as QUERYID,
<choose> <choose>
<when test="selective != null and selective.length &gt; 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
...@@ -386,7 +326,7 @@ ...@@ -386,7 +326,7 @@
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, user_id, coins_id, add_time, update_time, deleted id, user_id, item_id, add_time, update_time, deleted
</otherwise> </otherwise>
</choose> </choose>
from footprint from footprint
......
...@@ -26,6 +26,8 @@ public class UserInfo implements Serializable { ...@@ -26,6 +26,8 @@ public class UserInfo implements Serializable {
private Byte status;//状态 private Byte status;//状态
private String registerDate;//注册日期 private String registerDate;//注册日期
// 微信号
private String wechatId;
public String getCountry() { public String getCountry() {
return country; return country;
...@@ -99,6 +101,14 @@ public class UserInfo implements Serializable { ...@@ -99,6 +101,14 @@ public class UserInfo implements Serializable {
this.phone = phone; this.phone = phone;
} }
public String getWechatId() {
return wechatId;
}
public void setWechatId(String wechatId) {
this.wechatId = phone;
}
public Byte getUserLevel() { public Byte getUserLevel() {
return userLevel; return userLevel;
} }
......
package com.wwdz.ch.wx.entity.request;
import com.xxdxxs.entity.Entity;
import lombok.Data;
@Data
public class UserRequestDto implements Entity {
private Long userId;
private String mobile;
private String code;
private String avatarUrl;
private Long shareUserId;
private String nickname;
private String wechatId;
private String beforeMobile;
private String afterMobile;
}
package com.wwdz.ch.wx.service.impl; package com.wwdz.ch.wx.impl;
import com.wwdz.ch.wx.service.CategoryService; import com.wwdz.ch.wx.service.CategoryService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
......
package com.wwdz.ch.wx.service.impl; package com.wwdz.ch.wx.impl;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.UserItemsRelationDao; import com.wwdz.ch.db.dao.UserItemsRelationDao;
...@@ -31,11 +31,11 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -31,11 +31,11 @@ public class FavoritesServiceImpl implements FavoritesService {
private static final Logger logger = LoggerFactory.getLogger(FavoritesServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(FavoritesServiceImpl.class);
@Autowired @Autowired
private FavoritesDao favoritesManager; private FavoritesDao favoritesDao;
@Autowired @Autowired
private FavoritesItemsRelationDao favoritesItemsRelationManager; private FavoritesItemsRelationDao favoritesItemsRelationDao;
@Autowired @Autowired
private UserItemsRelationDao userItemsRelationManager; private UserItemsRelationDao userItemsRelationDao;
@Autowired @Autowired
private ItemManager itemManager; private ItemManager itemManager;
...@@ -53,7 +53,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -53,7 +53,7 @@ public class FavoritesServiceImpl implements FavoritesService {
favorites.setUpdateTime(date); favorites.setUpdateTime(date);
favorites.setDeleted(false); favorites.setDeleted(false);
favorites.setSort(1); favorites.setSort(1);
favoritesManager.insert(favorites); favoritesDao.insert(favorites);
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
logger.error("新建默认收藏册失败,原因:" + e.getMessage(), e); logger.error("新建默认收藏册失败,原因:" + e.getMessage(), e);
...@@ -65,7 +65,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -65,7 +65,7 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override @Override
public Result page(FavoritesRequestDto dto) { public Result page(FavoritesRequestDto dto) {
try { try {
return Result.success(favoritesManager.pageByUserId(dto.getUserId(), dto.getPage(), dto.getSize())); return Result.success(favoritesDao.pageByUserId(dto.getUserId(), dto.getPage(), dto.getSize()));
} catch (Exception e) { } catch (Exception e) {
logger.error("查询收藏册列表失败,原因:" + e.getMessage(), e); logger.error("查询收藏册列表失败,原因:" + e.getMessage(), e);
return Result.failed(-1, "查询收藏册列表失败"); return Result.failed(-1, "查询收藏册列表失败");
...@@ -75,7 +75,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -75,7 +75,7 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override @Override
public Result list(FavoritesRequestDto dto) { public Result list(FavoritesRequestDto dto) {
try { try {
return Result.success(favoritesManager.listByUserId(dto.getUserId())); return Result.success(favoritesDao.listByUserId(dto.getUserId()));
} catch (Exception e) { } catch (Exception e) {
logger.error("获取收藏册列表失败,原因:" + e.getMessage(), e); logger.error("获取收藏册列表失败,原因:" + e.getMessage(), e);
return Result.failed(-1, "获取收藏册列表失败"); return Result.failed(-1, "获取收藏册列表失败");
...@@ -87,7 +87,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -87,7 +87,7 @@ public class FavoritesServiceImpl implements FavoritesService {
public Result add(FavoritesRequestDto dto) { public Result add(FavoritesRequestDto dto) {
try { try {
// 判断收藏册标题是否已存在 // 判断收藏册标题是否已存在
if (favoritesManager.isExisted(null, dto.getUserId(), dto.getTitle())) { if (favoritesDao.isExisted(null, dto.getUserId(), dto.getTitle())) {
return Result.failed(-1, "收藏册的标题不能重复"); return Result.failed(-1, "收藏册的标题不能重复");
} }
...@@ -101,7 +101,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -101,7 +101,7 @@ public class FavoritesServiceImpl implements FavoritesService {
favorites.setUpdateTime(date); favorites.setUpdateTime(date);
favorites.setDeleted(false); favorites.setDeleted(false);
favorites.setSort(0); favorites.setSort(0);
favoritesManager.insert(favorites); favoritesDao.insert(favorites);
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
logger.error("新增收藏册失败,原因:" + e.getMessage(), e); logger.error("新增收藏册失败,原因:" + e.getMessage(), e);
...@@ -114,12 +114,12 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -114,12 +114,12 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override @Override
public Result update(FavoritesRequestDto dto) { public Result update(FavoritesRequestDto dto) {
try { try {
Favorites favorites = favoritesManager.info(dto.getId()); Favorites favorites = favoritesDao.info(dto.getId());
if (Objects.isNull(favorites)) { if (Objects.isNull(favorites)) {
return Result.failed("数据异常,记录不存在"); return Result.failed("数据异常,记录不存在");
} }
// 判断收藏册标题是否已存在 // 判断收藏册标题是否已存在
if (favoritesManager.isExisted(dto.getId(), dto.getUserId(), dto.getTitle())) { if (favoritesDao.isExisted(dto.getId(), dto.getUserId(), dto.getTitle())) {
return Result.failed("收藏册的标题不能重复"); return Result.failed("收藏册的标题不能重复");
} }
...@@ -127,7 +127,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -127,7 +127,7 @@ public class FavoritesServiceImpl implements FavoritesService {
favorites.setDescription(dto.getDescription()); favorites.setDescription(dto.getDescription());
favorites.setImages(dto.getImages()); favorites.setImages(dto.getImages());
favorites.setUpdateTime(new Date()); favorites.setUpdateTime(new Date());
favoritesManager.update(favorites); favoritesDao.update(favorites);
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
logger.error("新增收藏册失败,原因:" + e.getMessage(), e); logger.error("新增收藏册失败,原因:" + e.getMessage(), e);
...@@ -139,7 +139,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -139,7 +139,7 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override @Override
public Result info(FavoritesRequestDto dto) { public Result info(FavoritesRequestDto dto) {
try { try {
Favorites favorites = favoritesManager.info(dto.getId()); Favorites favorites = favoritesDao.info(dto.getId());
if (Objects.isNull(favorites)) { if (Objects.isNull(favorites)) {
return Result.failed("数据异常,记录不存在"); return Result.failed("数据异常,记录不存在");
} }
...@@ -154,13 +154,13 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -154,13 +154,13 @@ public class FavoritesServiceImpl implements FavoritesService {
@Override @Override
public Result delete(FavoritesRequestDto dto) { public Result delete(FavoritesRequestDto dto) {
try { try {
List<FavoritesItemsRelation> favoritesItemsList = favoritesItemsRelationManager.listByFavoritesId(dto.getId(), null); List<FavoritesItemsRelation> favoritesItemsList = favoritesItemsRelationDao.listByFavoritesId(dto.getId(), null);
if (CollectionUtils.isNotEmpty(favoritesItemsList)) { if (CollectionUtils.isNotEmpty(favoritesItemsList)) {
return Result.failed("收藏册内有藏品,请先移除藏品"); return Result.failed("收藏册内有藏品,请先移除藏品");
} }
// 删除收藏册 // 删除收藏册
favoritesManager.delete(dto.getId(), null); favoritesDao.delete(dto.getId(), null);
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
logger.error("删除收藏册失败,原因:" + e.getMessage(), e); logger.error("删除收藏册失败,原因:" + e.getMessage(), e);
...@@ -174,11 +174,11 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -174,11 +174,11 @@ public class FavoritesServiceImpl implements FavoritesService {
public Result batchDelete(FavoritesRequestDto dto) { public Result batchDelete(FavoritesRequestDto dto) {
try { try {
// 批量删除收藏册下用户创建的钱币 // 批量删除收藏册下用户创建的钱币
List<FavoritesItemsRelation> list = favoritesItemsRelationManager.listByFavoritesId(null, dto.getIds()); List<FavoritesItemsRelation> list = favoritesItemsRelationDao.listByFavoritesId(null, dto.getIds());
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
List<Long> favoritesItemsIds = list.stream() List<Long> favoritesItemsIds = list.stream()
.map(FavoritesItemsRelation::getItemId).collect(Collectors.toList()); .map(FavoritesItemsRelation::getItemId).collect(Collectors.toList());
List<UserItemsRelation> usersItemsList = userItemsRelationManager.listByUserIds(dto.getUserId(), null); List<UserItemsRelation> usersItemsList = userItemsRelationDao.listByUserIds(dto.getUserId(), null);
if (CollectionUtils.isNotEmpty(usersItemsList)) { if (CollectionUtils.isNotEmpty(usersItemsList)) {
List<Long> usersItemsIds = usersItemsList.stream() List<Long> usersItemsIds = usersItemsList.stream()
.map(UserItemsRelation::getItemId).collect(Collectors.toList()); .map(UserItemsRelation::getItemId).collect(Collectors.toList());
...@@ -191,10 +191,10 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -191,10 +191,10 @@ public class FavoritesServiceImpl implements FavoritesService {
} }
// 删除收藏册和钱币的关联 // 删除收藏册和钱币的关联
favoritesItemsRelationManager.deleteByFavoritesId(null, dto.getIds()); favoritesItemsRelationDao.deleteByFavoritesId(null, dto.getIds());
// 删除收藏册 // 删除收藏册
favoritesManager.delete(null, dto.getIds()); favoritesDao.delete(null, dto.getIds());
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
logger.error("批量删除收藏册失败,原因:" + e.getMessage(), e); logger.error("批量删除收藏册失败,原因:" + e.getMessage(), e);
...@@ -208,7 +208,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -208,7 +208,7 @@ public class FavoritesServiceImpl implements FavoritesService {
public Result removeItem(ItemRequestDto dto) { public Result removeItem(ItemRequestDto dto) {
try { try {
// 批量删除收藏册下用户创建的钱币 // 批量删除收藏册下用户创建的钱币
List<UserItemsRelation> usersItemsList = userItemsRelationManager.listByUserIds(dto.getUserId(), null); List<UserItemsRelation> usersItemsList = userItemsRelationDao.listByUserIds(dto.getUserId(), null);
if (CollectionUtils.isNotEmpty(usersItemsList)) { if (CollectionUtils.isNotEmpty(usersItemsList)) {
List<Long> usersItemsIds = usersItemsList.stream() List<Long> usersItemsIds = usersItemsList.stream()
.map(UserItemsRelation::getItemId).collect(Collectors.toList()); .map(UserItemsRelation::getItemId).collect(Collectors.toList());
...@@ -220,7 +220,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -220,7 +220,7 @@ public class FavoritesServiceImpl implements FavoritesService {
} }
// 删除收藏册和钱币的关联 // 删除收藏册和钱币的关联
favoritesItemsRelationManager.deleteByChosen(dto.getFavoritesId(), dto.getItemIds()); favoritesItemsRelationDao.deleteByChosen(dto.getFavoritesId(), dto.getItemIds());
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
logger.info("收藏册取消收藏失败,原因:" + e.getMessage(), e); logger.info("收藏册取消收藏失败,原因:" + e.getMessage(), e);
...@@ -234,7 +234,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -234,7 +234,7 @@ public class FavoritesServiceImpl implements FavoritesService {
public Result moveItem(ItemRequestDto dto) { public Result moveItem(ItemRequestDto dto) {
try { try {
// 删除原收藏册和藏品关联记录 // 删除原收藏册和藏品关联记录
favoritesItemsRelationManager.deleteByChosen(dto.getBeforeFavoritesId(), dto.getItemIds()); favoritesItemsRelationDao.deleteByChosen(dto.getBeforeFavoritesId(), dto.getItemIds());
// 新增新收藏册和藏品关联记录 // 新增新收藏册和藏品关联记录
Date now = new Date(); Date now = new Date();
...@@ -247,7 +247,7 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -247,7 +247,7 @@ public class FavoritesServiceImpl implements FavoritesService {
list.add(record); list.add(record);
} }
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
favoritesItemsRelationManager.batchInsert(list); favoritesItemsRelationDao.batchInsert(list);
} }
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
......
package com.wwdz.ch.wx.service.impl; package com.wwdz.ch.wx.impl;
import com.wwdz.ch.core.consts.CommonEnum; import com.wwdz.ch.core.consts.CommonEnum;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
...@@ -20,7 +20,9 @@ import org.springframework.stereotype.Service; ...@@ -20,7 +20,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Objects; import java.util.Objects;
@Service @Service
...@@ -35,6 +37,17 @@ public class ItemServiceImpl implements ItemService { ...@@ -35,6 +37,17 @@ public class ItemServiceImpl implements ItemService {
@Autowired @Autowired
private CategoryManager categoryManager; private CategoryManager categoryManager;
@Override
public Result page(ItemRequestDto dto) {
return null;
}
@Override
public Result list(ItemRequestDto dto) {
return null;
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public Result add(ItemRequestDto dto) { public Result add(ItemRequestDto dto) {
...@@ -115,8 +128,49 @@ public class ItemServiceImpl implements ItemService { ...@@ -115,8 +128,49 @@ public class ItemServiceImpl implements ItemService {
if (null == item.getId()) { if (null == item.getId()) {
return Result.failed("数据异常,该藏品不存在"); return Result.failed("数据异常,该藏品不存在");
} }
item.setName(dto.getName());
item.setCid(dto.getCid());
item.setImages(dto.getImages());
item.setPrice(Long.parseLong(dto.getPrice()) * 100);
item.setDetail(dto.getDetail());
Date now = new Date();
item.setUpdateTime(now);
item.setSourceType(CommonEnum.SourceTypeEnum.USER_UPLOAD.getCode());
item.setIsDeleted(false);
itemManager.update(item);
// 删除藏品和原收藏册关联
List<Long> itemIds = new ArrayList<>();
itemIds.add(item.getId());
favoritesItemsRelationManager.deleteByChosen(dto.getBeforeFavoritesId(), itemIds);
// 新增藏品和新收藏册关联
FavoritesItemsRelation favoritesItemsRelation = new FavoritesItemsRelation();
favoritesItemsRelation.setUserId(dto.getUserId());
favoritesItemsRelation.setFavoritesId(dto.getAfterFavoritesId());
favoritesItemsRelation.setItemId(item.getId());
favoritesItemsRelationManager.insert(favoritesItemsRelation);
return Result.success();
} catch (Exception e) {
logger.error("修改藏品失败,原因:" + e.getMessage(), e);
return Result.failed("修改藏品失败");
}
}
@Override
public Result update(ItemRequestDto dto) {
try {
Item item = itemManager.findDetails(dto.getId());
if (null == item.getId()) {
return Result.failed("数据异常,该藏品不存在");
}
// 新增藏品和收藏册关联
FavoritesItemsRelation favoritesItemsRelation = new FavoritesItemsRelation();
favoritesItemsRelation.setUserId(dto.getUserId());
favoritesItemsRelation.setFavoritesId(dto.getFavoritesId());
favoritesItemsRelation.setItemId(item.getId());
favoritesItemsRelationManager.insert(favoritesItemsRelation);
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
logger.error("收藏藏品失败,原因:" + e.getMessage(), e); logger.error("收藏藏品失败,原因:" + e.getMessage(), e);
......
...@@ -4,9 +4,15 @@ import com.wwdz.ch.core.type.Result; ...@@ -4,9 +4,15 @@ import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.wx.entity.request.ItemRequestDto; import com.wwdz.ch.wx.entity.request.ItemRequestDto;
public interface ItemService { public interface ItemService {
Result page(ItemRequestDto dto);
Result list(ItemRequestDto dto);
Result add(ItemRequestDto dto); Result add(ItemRequestDto dto);
Result info(ItemRequestDto dto); Result info(ItemRequestDto dto);
Result collect(ItemRequestDto dto); Result collect(ItemRequestDto dto);
Result update(ItemRequestDto dto);
} }
This diff is collapsed.
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