Commit 8f0701c2 authored by muhong's avatar muhong

新增修改 小程序相关接口

parent 978eab79
...@@ -13,6 +13,7 @@ public interface FavoritesItemsRelationDao { ...@@ -13,6 +13,7 @@ public interface FavoritesItemsRelationDao {
List<FavoritesItemsRelation> listByFavoritesId(Long favoritesId, List<Long> favoritesIds); List<FavoritesItemsRelation> listByFavoritesId(Long favoritesId, List<Long> favoritesIds);
FavoritesItemsRelation selectByUserIdItemId(Long userId, Long itemId); FavoritesItemsRelation selectByUserIdItemId(Long userId, Long itemId);
PageInfo<FavoritesItemsRelation> pageByFavoritesId(Long favoritesId, int page, int size); PageInfo<FavoritesItemsRelation> pageByFavoritesId(Long favoritesId, int page, int size);
long count(Long itemId); long countByItemId(Long itemId);
boolean isCollected(Long userId, Long itemId); boolean isCollected(Long userId, Long itemId);
long countByFavoritesId(Long favoritesId);
} }
...@@ -9,6 +9,10 @@ public interface UserDao { ...@@ -9,6 +9,10 @@ public interface UserDao {
User queryById(Long id); User queryById(Long id);
boolean isExistedByNickname(Long userId, String nickname);
boolean isExistedByWechatId(Long userId, String wechatId);
int insert(User user); int insert(User user);
int updateById(User user); int updateById(User user);
......
...@@ -47,6 +47,7 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao ...@@ -47,6 +47,7 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria(); FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(favoritesId, criteria::andFavoritesIdEqualTo); JdbcHelper.ifPresent(favoritesId, criteria::andFavoritesIdEqualTo);
JdbcHelper.ifPresent(favoritesIds, criteria::andFavoritesIdIn); JdbcHelper.ifPresent(favoritesIds, criteria::andFavoritesIdIn);
example.orderBy("add_time desc");
return favoritesItemsRelationMapper.selectByExample(example); return favoritesItemsRelationMapper.selectByExample(example);
} }
...@@ -64,13 +65,14 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao ...@@ -64,13 +65,14 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
FavoritesItemsRelationExample example = new FavoritesItemsRelationExample(); FavoritesItemsRelationExample example = new FavoritesItemsRelationExample();
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria(); FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
criteria.andFavoritesIdEqualTo(favoritesId); criteria.andFavoritesIdEqualTo(favoritesId);
example.orderBy("add_time desc");
PageHelper.startPage(page, size); PageHelper.startPage(page, size);
List<FavoritesItemsRelation> list = favoritesItemsRelationMapper.selectByExample(example); List<FavoritesItemsRelation> list = favoritesItemsRelationMapper.selectByExample(example);
return new PageInfo<>(list); return new PageInfo<>(list);
} }
@Override @Override
public long count(Long itemId) { public long countByItemId(Long itemId) {
FavoritesItemsRelationExample example = new FavoritesItemsRelationExample(); FavoritesItemsRelationExample example = new FavoritesItemsRelationExample();
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria(); FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
criteria.andItemIdEqualTo(itemId); criteria.andItemIdEqualTo(itemId);
...@@ -85,4 +87,12 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao ...@@ -85,4 +87,12 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
criteria.andItemIdEqualTo(itemId); criteria.andItemIdEqualTo(itemId);
return favoritesItemsRelationMapper.countByExample(example) > 0; return favoritesItemsRelationMapper.countByExample(example) > 0;
} }
@Override
public long countByFavoritesId(Long favoritesId) {
FavoritesItemsRelationExample example = new FavoritesItemsRelationExample();
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(favoritesId, criteria::andFavoritesIdEqualTo);
return favoritesItemsRelationMapper.countByExample(example);
}
} }
...@@ -36,6 +36,20 @@ public class UserDaoImpl implements UserDao { ...@@ -36,6 +36,20 @@ public class UserDaoImpl implements UserDao {
return userMapper.selectOneByExample(example); return userMapper.selectOneByExample(example);
} }
@Override
public boolean isExistedByNickname(Long userId, String nickname) {
UserExample example = new UserExample();
example.or().andIdNotEqualTo(userId).andNicknameEqualTo(nickname).andDeletedEqualTo(false);
return userMapper.countByExample(example) > 0;
}
@Override
public boolean isExistedByWechatId(Long userId, String wechatId) {
UserExample example = new UserExample();
example.or().andIdNotEqualTo(userId).andWechatIdEqualTo(wechatId).andDeletedEqualTo(false);
return userMapper.countByExample(example) > 0;
}
@Override @Override
public int insert(User user) { public int insert(User user) {
return userMapper.insert(user); return userMapper.insert(user);
......
...@@ -9,7 +9,7 @@ import java.util.Date; ...@@ -9,7 +9,7 @@ import java.util.Date;
/** /**
* @author shiyu * @author shiyu
* @date 2023/07/26 * @date 2023/08/07
*/ */
@Data @Data
public class User implements Serializable { public class User implements Serializable {
...@@ -83,6 +83,16 @@ public class User implements Serializable { ...@@ -83,6 +83,16 @@ public class User implements Serializable {
*/ */
private String avatar; private String avatar;
/**
* 用户简介
*/
private String profile;
/**
* 用户背景图片
*/
private String background;
/** /**
* 微信登录openid * 微信登录openid
*/ */
...@@ -134,6 +144,8 @@ public class User implements Serializable { ...@@ -134,6 +144,8 @@ public class User implements Serializable {
sb.append(", nickname=").append(nickname); sb.append(", nickname=").append(nickname);
sb.append(", mobile=").append(mobile); sb.append(", mobile=").append(mobile);
sb.append(", avatar=").append(avatar); sb.append(", avatar=").append(avatar);
sb.append(", profile=").append(profile);
sb.append(", background=").append(background);
sb.append(", weixinOpenid=").append(weixinOpenid); sb.append(", weixinOpenid=").append(weixinOpenid);
sb.append(", wechatId=").append(wechatId); sb.append(", wechatId=").append(wechatId);
sb.append(", status=").append(status); sb.append(", status=").append(status);
...@@ -169,6 +181,8 @@ public class User implements Serializable { ...@@ -169,6 +181,8 @@ public class User implements Serializable {
&& (this.getNickname() == null ? other.getNickname() == null : this.getNickname().equals(other.getNickname())) && (this.getNickname() == null ? other.getNickname() == null : this.getNickname().equals(other.getNickname()))
&& (this.getMobile() == null ? other.getMobile() == null : this.getMobile().equals(other.getMobile())) && (this.getMobile() == null ? other.getMobile() == null : this.getMobile().equals(other.getMobile()))
&& (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar())) && (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar()))
&& (this.getProfile() == null ? other.getProfile() == null : this.getProfile().equals(other.getProfile()))
&& (this.getBackground() == null ? other.getBackground() == null : this.getBackground().equals(other.getBackground()))
&& (this.getWeixinOpenid() == null ? other.getWeixinOpenid() == null : this.getWeixinOpenid().equals(other.getWeixinOpenid())) && (this.getWeixinOpenid() == null ? other.getWeixinOpenid() == null : this.getWeixinOpenid().equals(other.getWeixinOpenid()))
&& (this.getWechatId() == null ? other.getWechatId() == null : this.getWechatId().equals(other.getWechatId())) && (this.getWechatId() == null ? other.getWechatId() == null : this.getWechatId().equals(other.getWechatId()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
...@@ -193,6 +207,8 @@ public class User implements Serializable { ...@@ -193,6 +207,8 @@ public class User implements Serializable {
result = prime * result + ((getNickname() == null) ? 0 : getNickname().hashCode()); result = prime * result + ((getNickname() == null) ? 0 : getNickname().hashCode());
result = prime * result + ((getMobile() == null) ? 0 : getMobile().hashCode()); result = prime * result + ((getMobile() == null) ? 0 : getMobile().hashCode());
result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode()); result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode());
result = prime * result + ((getProfile() == null) ? 0 : getProfile().hashCode());
result = prime * result + ((getBackground() == null) ? 0 : getBackground().hashCode());
result = prime * result + ((getWeixinOpenid() == null) ? 0 : getWeixinOpenid().hashCode()); result = prime * result + ((getWeixinOpenid() == null) ? 0 : getWeixinOpenid().hashCode());
result = prime * result + ((getWechatId() == null) ? 0 : getWechatId().hashCode()); result = prime * result + ((getWechatId() == null) ? 0 : getWechatId().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
...@@ -233,6 +249,8 @@ public class User implements Serializable { ...@@ -233,6 +249,8 @@ public class User implements Serializable {
nickname("nickname", "nickname", "VARCHAR", false), nickname("nickname", "nickname", "VARCHAR", false),
mobile("mobile", "mobile", "VARCHAR", false), mobile("mobile", "mobile", "VARCHAR", false),
avatar("avatar", "avatar", "VARCHAR", false), avatar("avatar", "avatar", "VARCHAR", false),
profile("profile", "profile", "VARCHAR", false),
background("background", "background", "VARCHAR", false),
weixinOpenid("weixin_openid", "weixinOpenid", "VARCHAR", false), weixinOpenid("weixin_openid", "weixinOpenid", "VARCHAR", false),
wechatId("wechat_id", "wechatId", "VARCHAR", false), wechatId("wechat_id", "wechatId", "VARCHAR", false),
status("status", "status", "TINYINT", true), status("status", "status", "TINYINT", true),
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
<result column="nickname" jdbcType="VARCHAR" property="nickname" /> <result column="nickname" jdbcType="VARCHAR" property="nickname" />
<result column="mobile" jdbcType="VARCHAR" property="mobile" /> <result column="mobile" jdbcType="VARCHAR" property="mobile" />
<result column="avatar" jdbcType="VARCHAR" property="avatar" /> <result column="avatar" jdbcType="VARCHAR" property="avatar" />
<result column="profile" jdbcType="VARCHAR" property="profile" />
<result column="background" jdbcType="VARCHAR" property="background" />
<result column="weixin_openid" jdbcType="VARCHAR" property="weixinOpenid" /> <result column="weixin_openid" jdbcType="VARCHAR" property="weixinOpenid" />
<result column="wechat_id" jdbcType="VARCHAR" property="wechatId" /> <result column="wechat_id" jdbcType="VARCHAR" property="wechatId" />
<result column="status" jdbcType="TINYINT" property="status" /> <result column="status" jdbcType="TINYINT" property="status" />
...@@ -81,8 +83,8 @@ ...@@ -81,8 +83,8 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level, id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, wechat_id, `status`, add_time, update_time, nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
deleted, share_user_id add_time, update_time, deleted, share_user_id
</sql> </sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.UserExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.wwdz.ch.db.domain.UserExample" resultMap="BaseResultMap">
select select
...@@ -118,8 +120,8 @@ ...@@ -118,8 +120,8 @@
</when> </when>
<otherwise> <otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level, id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, wechat_id, `status`, add_time, update_time, nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
deleted, share_user_id add_time, update_time, deleted, share_user_id
</otherwise> </otherwise>
</choose> </choose>
from user from user
...@@ -171,8 +173,8 @@ ...@@ -171,8 +173,8 @@
</when> </when>
<otherwise> <otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level, id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, wechat_id, `status`, add_time, update_time, nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
deleted, share_user_id add_time, update_time, deleted, share_user_id
</otherwise> </otherwise>
</choose> </choose>
from user from user
...@@ -195,15 +197,17 @@ ...@@ -195,15 +197,17 @@
insert into user (username, `password`, gender, insert into user (username, `password`, gender,
birthday, last_login_time, last_login_ip, birthday, last_login_time, last_login_ip,
user_level, nickname, mobile, user_level, nickname, mobile,
avatar, weixin_openid, wechat_id, avatar, profile, background,
`status`, add_time, update_time, weixin_openid, wechat_id, `status`,
deleted, share_user_id) add_time, update_time, deleted,
share_user_id)
values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT}, values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT},
#{birthday,jdbcType=DATE}, #{lastLoginTime,jdbcType=TIMESTAMP}, #{lastLoginIp,jdbcType=VARCHAR}, #{birthday,jdbcType=DATE}, #{lastLoginTime,jdbcType=TIMESTAMP}, #{lastLoginIp,jdbcType=VARCHAR},
#{userLevel,jdbcType=TINYINT}, #{nickname,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{userLevel,jdbcType=TINYINT}, #{nickname,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{avatar,jdbcType=VARCHAR}, #{weixinOpenid,jdbcType=VARCHAR}, #{wechatId,jdbcType=VARCHAR}, #{avatar,jdbcType=VARCHAR}, #{profile,jdbcType=VARCHAR}, #{background,jdbcType=VARCHAR},
#{status,jdbcType=TINYINT}, #{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{weixinOpenid,jdbcType=VARCHAR}, #{wechatId,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{deleted,jdbcType=BIT}, #{shareUserId,jdbcType=BIGINT}) #{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT},
#{shareUserId,jdbcType=BIGINT})
</insert> </insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.User"> <insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.User">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
...@@ -241,6 +245,12 @@ ...@@ -241,6 +245,12 @@
<if test="avatar != null"> <if test="avatar != null">
avatar, avatar,
</if> </if>
<if test="profile != null">
profile,
</if>
<if test="background != null">
background,
</if>
<if test="weixinOpenid != null"> <if test="weixinOpenid != null">
weixin_openid, weixin_openid,
</if> </if>
...@@ -294,6 +304,12 @@ ...@@ -294,6 +304,12 @@
<if test="avatar != null"> <if test="avatar != null">
#{avatar,jdbcType=VARCHAR}, #{avatar,jdbcType=VARCHAR},
</if> </if>
<if test="profile != null">
#{profile,jdbcType=VARCHAR},
</if>
<if test="background != null">
#{background,jdbcType=VARCHAR},
</if>
<if test="weixinOpenid != null"> <if test="weixinOpenid != null">
#{weixinOpenid,jdbcType=VARCHAR}, #{weixinOpenid,jdbcType=VARCHAR},
</if> </if>
...@@ -359,6 +375,12 @@ ...@@ -359,6 +375,12 @@
<if test="record.avatar != null"> <if test="record.avatar != null">
avatar = #{record.avatar,jdbcType=VARCHAR}, avatar = #{record.avatar,jdbcType=VARCHAR},
</if> </if>
<if test="record.profile != null">
profile = #{record.profile,jdbcType=VARCHAR},
</if>
<if test="record.background != null">
background = #{record.background,jdbcType=VARCHAR},
</if>
<if test="record.weixinOpenid != null"> <if test="record.weixinOpenid != null">
weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR}, weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR},
</if> </if>
...@@ -398,6 +420,8 @@ ...@@ -398,6 +420,8 @@
nickname = #{record.nickname,jdbcType=VARCHAR}, nickname = #{record.nickname,jdbcType=VARCHAR},
mobile = #{record.mobile,jdbcType=VARCHAR}, mobile = #{record.mobile,jdbcType=VARCHAR},
avatar = #{record.avatar,jdbcType=VARCHAR}, avatar = #{record.avatar,jdbcType=VARCHAR},
profile = #{record.profile,jdbcType=VARCHAR},
background = #{record.background,jdbcType=VARCHAR},
weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR}, weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR},
wechat_id = #{record.wechatId,jdbcType=VARCHAR}, wechat_id = #{record.wechatId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=TINYINT}, `status` = #{record.status,jdbcType=TINYINT},
...@@ -442,6 +466,12 @@ ...@@ -442,6 +466,12 @@
<if test="avatar != null"> <if test="avatar != null">
avatar = #{avatar,jdbcType=VARCHAR}, avatar = #{avatar,jdbcType=VARCHAR},
</if> </if>
<if test="profile != null">
profile = #{profile,jdbcType=VARCHAR},
</if>
<if test="background != null">
background = #{background,jdbcType=VARCHAR},
</if>
<if test="weixinOpenid != null"> <if test="weixinOpenid != null">
weixin_openid = #{weixinOpenid,jdbcType=VARCHAR}, weixin_openid = #{weixinOpenid,jdbcType=VARCHAR},
</if> </if>
...@@ -478,6 +508,8 @@ ...@@ -478,6 +508,8 @@
nickname = #{nickname,jdbcType=VARCHAR}, nickname = #{nickname,jdbcType=VARCHAR},
mobile = #{mobile,jdbcType=VARCHAR}, mobile = #{mobile,jdbcType=VARCHAR},
avatar = #{avatar,jdbcType=VARCHAR}, avatar = #{avatar,jdbcType=VARCHAR},
profile = #{profile,jdbcType=VARCHAR},
background = #{background,jdbcType=VARCHAR},
weixin_openid = #{weixinOpenid,jdbcType=VARCHAR}, weixin_openid = #{weixinOpenid,jdbcType=VARCHAR},
wechat_id = #{wechatId,jdbcType=VARCHAR}, wechat_id = #{wechatId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=TINYINT}, `status` = #{status,jdbcType=TINYINT},
...@@ -521,8 +553,8 @@ ...@@ -521,8 +553,8 @@
</when> </when>
<otherwise> <otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level, id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, wechat_id, `status`, add_time, update_time, nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
deleted, share_user_id add_time, update_time, deleted, share_user_id
</otherwise> </otherwise>
</choose> </choose>
from user from user
......
package com.wwdz.ch.wx.constant;
import java.util.HashMap;
import java.util.Map;
public class CacheCodeEnum {
public enum SmsTypeEnum {
LOGIN("LOGIN:", "登录"),
UPDATE("UPDATE:", "修改手机号"),
;
private String code;
private String name;
SmsTypeEnum(String code, String name) {
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
public static String getDesByCode(String code) {
for (SmsTypeEnum afterSaleStateEnum : SmsTypeEnum.values()) {
if (code.equals(afterSaleStateEnum.getCode())) {
return afterSaleStateEnum.getName();
}
}
return null;
}
/**
* 返回map
* @return
*/
public static Map<String, String> getSmsTypeEnumMap() {
Map<String, String> map = new HashMap<>();
for (SmsTypeEnum afterSaleStateEnum : SmsTypeEnum.values()) {
map.put(afterSaleStateEnum.getCode(), afterSaleStateEnum.getName());
}
return map;
}
}
}
...@@ -15,4 +15,7 @@ public class UserRequestDto implements Entity { ...@@ -15,4 +15,7 @@ public class UserRequestDto implements Entity {
private String wechatId; private String wechatId;
private String beforeMobile; private String beforeMobile;
private String afterMobile; private String afterMobile;
private String profile;
private String background;
private String smsType;
} }
package com.wwdz.ch.wx.impl; package com.wwdz.ch.wx.impl;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.FavoritesDao;
import com.wwdz.ch.db.dao.FavoritesItemsRelationDao;
import com.wwdz.ch.db.dao.ItemManager;
import com.wwdz.ch.db.dao.UserItemsRelationDao; import com.wwdz.ch.db.dao.UserItemsRelationDao;
import com.wwdz.ch.db.domain.Favorites; import com.wwdz.ch.db.domain.Favorites;
import com.wwdz.ch.db.domain.FavoritesItemsRelation; import com.wwdz.ch.db.domain.FavoritesItemsRelation;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.db.domain.UserItemsRelation; import com.wwdz.ch.db.domain.UserItemsRelation;
import com.wwdz.ch.db.dto.request.CoinRequestDto; import com.wwdz.ch.db.dto.request.CoinRequestDto;
import com.wwdz.ch.db.dao.FavoritesItemsRelationDao;
import com.wwdz.ch.db.dao.FavoritesDao;
import com.wwdz.ch.db.dao.ItemManager;
import com.wwdz.ch.wx.entity.request.ItemRequestDto;
import com.wwdz.ch.wx.entity.request.FavoritesRequestDto; import com.wwdz.ch.wx.entity.request.FavoritesRequestDto;
import com.wwdz.ch.wx.entity.request.ItemRequestDto;
import com.wwdz.ch.wx.entity.vo.ItemResponseVo;
import com.wwdz.ch.wx.service.FavoritesService; import com.wwdz.ch.wx.service.FavoritesService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -150,6 +153,40 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -150,6 +153,40 @@ public class FavoritesServiceImpl implements FavoritesService {
} }
} }
@Override
public Result itemList(FavoritesRequestDto dto) {
try {
PageInfo<ItemResponseVo> page = new PageInfo<>();
page.setPageNum(dto.getPage());
page.setPageSize(dto.getSize());
page.setTotal(0L);
page.setList(new ArrayList<>());
PageInfo<FavoritesItemsRelation> relationPage = favoritesItemsRelationDao.pageByFavoritesId(dto.getId(), dto.getPage(), dto.getSize());
if (relationPage.getList().isEmpty()) {
return Result.success(page);
}
List<ItemResponseVo> list = new ArrayList<>();
for (FavoritesItemsRelation relation : relationPage.getList()) {
ItemResponseVo vo = new ItemResponseVo();
Item item = itemManager.findDetails(relation.getItemId());
vo.setId(relation.getItemId());
vo.setName(item.getName());
vo.setImages(item.getImages());
vo.setPrice(String.valueOf(item.getPrice() * 100));
vo.setDetail(item.getDetail());
vo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), relation.getItemId()) ? 1 : 0);
vo.setCollectCount(favoritesItemsRelationDao.countByItemId(relation.getItemId()));
list.add(vo);
}
page.setTotal(favoritesItemsRelationDao.countByFavoritesId(dto.getId()));
page.setList(list);
return Result.success(page);
} catch (Exception e) {
logger.error("查看收藏册的藏品列表失败,原因:" + e.getMessage(), e);
return Result.failed("查看收藏册的藏品列表失败");
}
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public Result delete(FavoritesRequestDto dto) { public Result delete(FavoritesRequestDto dto) {
......
...@@ -73,7 +73,7 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -73,7 +73,7 @@ public class FootPrintServiceImpl implements FootPrintService {
itemResponseVo.setDetail(item.getDetail()); itemResponseVo.setDetail(item.getDetail());
itemResponseVo.setPrice(String.valueOf(item.getPrice() / 100)); itemResponseVo.setPrice(String.valueOf(item.getPrice() / 100));
itemResponseVo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), footprint.getItemId()) ? 1 : 0); itemResponseVo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), footprint.getItemId()) ? 1 : 0);
itemResponseVo.setCollectCount(favoritesItemsRelationDao.count(footprint.getItemId())); itemResponseVo.setCollectCount(favoritesItemsRelationDao.countByItemId(footprint.getItemId()));
if (footprint.getAddTime().compareTo(today) >= 0) { if (footprint.getAddTime().compareTo(today) >= 0) {
todayList.add(itemResponseVo); todayList.add(itemResponseVo);
} }
...@@ -160,7 +160,7 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -160,7 +160,7 @@ public class FootPrintServiceImpl implements FootPrintService {
itemResponseVo.setDetail(item.getDetail()); itemResponseVo.setDetail(item.getDetail());
itemResponseVo.setPrice(String.valueOf(item.getPrice() / 100)); itemResponseVo.setPrice(String.valueOf(item.getPrice() / 100));
itemResponseVo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), footprint.getItemId()) ? 1 : 0); itemResponseVo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), footprint.getItemId()) ? 1 : 0);
itemResponseVo.setCollectCount(favoritesItemsRelationDao.count(footprint.getItemId())); itemResponseVo.setCollectCount(favoritesItemsRelationDao.countByItemId(footprint.getItemId()));
if (footprint.getAddTime().compareTo(today) >= 0) { if (footprint.getAddTime().compareTo(today) >= 0) {
todayList.add(itemResponseVo); todayList.add(itemResponseVo);
} }
......
...@@ -65,7 +65,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -65,7 +65,7 @@ public class ItemServiceImpl implements ItemService {
vo.setPrice(String.valueOf(item.getPrice() * 100)); vo.setPrice(String.valueOf(item.getPrice() * 100));
vo.setDetail(item.getDetail()); vo.setDetail(item.getDetail());
vo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), item.getId()) ? 1 : 0); vo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), item.getId()) ? 1 : 0);
vo.setCollectCount(favoritesItemsRelationDao.count(item.getId())); vo.setCollectCount(favoritesItemsRelationDao.countByItemId(item.getId()));
resultList.add(vo); resultList.add(vo);
} }
result.setList(resultList); result.setList(resultList);
......
...@@ -16,6 +16,8 @@ public interface FavoritesService { ...@@ -16,6 +16,8 @@ public interface FavoritesService {
Result info(FavoritesRequestDto dto); Result info(FavoritesRequestDto dto);
Result itemList(FavoritesRequestDto dto);
Result delete(FavoritesRequestDto dto); Result delete(FavoritesRequestDto dto);
Result batchDelete(FavoritesRequestDto dto); Result batchDelete(FavoritesRequestDto dto);
......
...@@ -13,6 +13,10 @@ public interface UserService { ...@@ -13,6 +13,10 @@ public interface UserService {
Result loginByMobile(UserRequestDto dto, HttpServletRequest request); Result loginByMobile(UserRequestDto dto, HttpServletRequest request);
Result updateProfile(UserRequestDto dto);
Result updateBackground(UserRequestDto dto);
Result updateNickname(UserRequestDto dto); Result updateNickname(UserRequestDto dto);
Result updateAvatar(UserRequestDto dto); Result updateAvatar(UserRequestDto dto);
......
...@@ -54,6 +54,12 @@ public class WxFavoritesController { ...@@ -54,6 +54,12 @@ public class WxFavoritesController {
return favoritesService.info(dto); return favoritesService.info(dto);
} }
@ApiOperation(value = "详情")
@PostMapping("/itemList")
public Result itemList(@RequestBody @Validated(Select.class) FavoritesRequestDto dto) {
return favoritesService.itemList(dto);
}
@ApiOperation(value = "单个删除") @ApiOperation(value = "单个删除")
@PostMapping("/delete") @PostMapping("/delete")
public Result delete(@RequestBody @Validated(Delete.class) FavoritesRequestDto dto) { public Result delete(@RequestBody @Validated(Delete.class) FavoritesRequestDto dto) {
......
...@@ -7,9 +7,11 @@ import com.wwdz.ch.core.util.ResponseUtil; ...@@ -7,9 +7,11 @@ import com.wwdz.ch.core.util.ResponseUtil;
import com.wwdz.ch.db.domain.UserAccountObsolete; import com.wwdz.ch.db.domain.UserAccountObsolete;
import com.wwdz.ch.db.service.DtsAccountService; import com.wwdz.ch.db.service.DtsAccountService;
import com.wwdz.ch.wx.annotation.LoginUser; import com.wwdz.ch.wx.annotation.LoginUser;
import com.wwdz.ch.wx.constant.CacheCodeEnum;
import com.wwdz.ch.wx.dao.WxLoginInfo; import com.wwdz.ch.wx.dao.WxLoginInfo;
import com.wwdz.ch.wx.entity.request.UserRequestDto; import com.wwdz.ch.wx.entity.request.UserRequestDto;
import com.wwdz.ch.wx.service.UserService; import com.wwdz.ch.wx.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* 用户服务 * 用户服务
...@@ -86,25 +89,125 @@ public class WxUserController { ...@@ -86,25 +89,125 @@ public class WxUserController {
return ResponseUtil.ok(data); return ResponseUtil.ok(data);
} }
@ApiOperation(value = "微信登录")
@PostMapping("/loginByWx") @PostMapping("/loginByWx")
public Result loginByWx(@RequestBody WxLoginInfo wxLoginInfo, HttpServletRequest request) { public Result loginByWx(@RequestBody WxLoginInfo wxLoginInfo, HttpServletRequest request) {
logger.info("【请求开始】微信登录,请求参数,wxLoginInfo:{}", JSONObject.toJSONString(wxLoginInfo)); logger.info("【请求开始】微信登录,请求参数,wxLoginInfo:{}", JSONObject.toJSONString(wxLoginInfo));
return userService.loginByWx(wxLoginInfo, request); return userService.loginByWx(wxLoginInfo, request);
} }
@PostMapping("/regCaptcha") @ApiOperation(value = "登录手机验证码")
@PostMapping("/loginRegCaptcha")
public Object registerCaptcha(@RequestBody UserRequestDto dto) { public Object registerCaptcha(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】请求验证码,请求参数,mobile:{}", dto.getMobile()); logger.info("【请求开始】请求验证码,请求参数,mobile:{}", dto.getMobile());
if (StringUtils.isBlank(dto.getMobile())) { if (StringUtils.isBlank(dto.getMobile())) {
return Result.failed("手机号不能为空"); return Result.failed("手机号不能为空");
} }
dto.setSmsType(CacheCodeEnum.SmsTypeEnum.LOGIN.getCode());
return userService.regCaptcha(dto); return userService.regCaptcha(dto);
} }
@ApiOperation(value = "手机验证码登录")
@PostMapping("/loginByMobile") @PostMapping("/loginByMobile")
public Result loginByMobile(@RequestBody UserRequestDto dto, HttpServletRequest request) { public Result loginByMobile(@RequestBody UserRequestDto dto, HttpServletRequest request) {
logger.info("【请求开始】手机号登录,请求参数,wxLoginInfo:{}", JSONObject.toJSONString(dto)); logger.info("【请求开始】手机号登录,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
return userService.loginByMobile(dto, request); return userService.loginByMobile(dto, request);
} }
@ApiOperation(value = "修改个性签名")
@PostMapping("/updateProfile")
public Result updateProfile(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】修改个性签名,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getProfile())) {
return Result.failed("个性签名不能为空");
}
return userService.updateProfile(dto);
}
@ApiOperation(value = "修改背景")
@PostMapping("/updateBackground")
public Result updateBackground(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】修改背景,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getBackground())) {
return Result.failed("背景图片路径不能为空");
}
return userService.updateBackground(dto);
}
@ApiOperation(value = "修改昵称")
@PostMapping("/updateNickname")
public Result updateNickname(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】修改昵称,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getNickname())) {
return Result.failed("昵称不能为空");
}
return userService.updateNickname(dto);
}
@ApiOperation(value = "修改头像")
@PostMapping("/updateAvatar")
public Result updateAvatar(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】修改头像,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getAvatarUrl())) {
return Result.failed("头像图片路径不能为空");
}
return userService.updateAvatar(dto);
}
@ApiOperation(value = "绑定微信号")
@PostMapping("/bindWechatId")
public Result bindWechatId(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】绑定微信号,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getWechatId())) {
return Result.failed("微信号不能为空");
}
return userService.bindWechatId(dto);
}
@ApiOperation(value = "修改手机验证码")
@PostMapping("/updateRegCaptcha")
public Object updateRegCaptcha(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】请求修改手机验证码,请求参数,mobile:{}", dto.getMobile());
if (StringUtils.isBlank(dto.getMobile())) {
return Result.failed("手机号不能为空");
}
dto.setSmsType(CacheCodeEnum.SmsTypeEnum.UPDATE.getCode());
return userService.regCaptcha(dto);
}
@ApiOperation(value = "修改手机号")
@PostMapping("/updateMobile")
public Result updateMobile(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】修改手机号,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getBeforeMobile())) {
return Result.failed("原手机号不能为空");
}
if (StringUtils.isBlank(dto.getAfterMobile())) {
return Result.failed("新手机号不能为空");
}
if (StringUtils.isBlank(dto.getSmsCode())) {
return Result.failed("验证码不能为空");
}
return userService.updateMobile(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