Commit c93e4f31 authored by licc's avatar licc

添加用户实体类

parent da2538d0
Pipeline #368 failed with stages
......@@ -6,8 +6,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @author 86187
......@@ -41,221 +39,4 @@ public interface UsersMapper extends BaseMapper<Users> {
*/
int delById(@Param("id") Integer id);
List<Users> getList();
/**
* 获取所有的非普通用户列表
*
* @return 非普通用户列表
*/
List<Users> findAllNotZeroUser();
Users findByName(String name);
String findPswByName(String UserName);
void save(Users users);
/**
* 获取用户信息
*
* @return 用户信息
*/
Users getUserById(@Param("id") Long id);
/**
* 获取用户信息
*
* @param userId 用户id
* @return 用户信息
*/
Users getByUserId(@Param("userId") String userId);
/**
* 获取用户信息
*
* @param userId 用户id
* @return 用户信息
*/
Integer ByUserId(@Param("userId") String userId);
/**
* 获取用户信息
*
* @param
* @return 用户信息
*/
Integer beInvitedCode1(@Param("beInvitedCode") String beInvitedCode);
/**
* 获取用户信息
*
* @param beInvitedCode 用户被邀请码
* @return 用户信息
*/
Users getByBeInvitedCode(@Param("beInvitedCode") String beInvitedCode);
/**
* 获取黄金树以上会员用户
*
* @return
*/
List<Users> getAllGoldUser();
/**
* 查询用户
*
* @param param
* @return
*/
public List<Users> getUsersListByMap(Map<String, Object> param);
//根据手机号查询用户Integer
Users queryUsersByPhone(@Param("userId") String userId);
//根据用户的推荐人邀请码比对推荐人的本人邀请码,查询推荐人的用户ID
Integer inviteCodeBeInvitedCode(@Param("beInvitedCode") Integer beInvitedCode);
/**
* 用户注册
*
* @param userId
* @param inviteCode
* @param beInvitedCode
* @param userLevel
*/
Integer insertbyint(@Param("userId") String userId, @Param("inviteCode") String inviteCode, @Param("beInvitedCode") String beInvitedCode, @Param("userLevel") Integer userLevel, @Param("headImage") String headImage, @Param("frozen") Integer frozen);
Integer save(@Param("userId") String userId, @Param("beInvitedCode") String beInvitedCode);
Users edit1(int userLevel, String intiveCode, String userId);
Integer getuserIdById(@Param("userId") String userId);
Integer getById(@Param("userId") String userId);
String BYQMById(@Param("userId") String userId);
/**
* 根据userid获取获取所有的直接推荐人
*
* @param inviteCode 用户本人的邀请码
* @return 所有填写此人的邀请码的用户
*/
List<Users> getByInviteCode(@Param("inviteCode") String inviteCode, @Param("userLevel") int userLevel);
/**
* 通过邀请码,获取用户信息
*
* @param inviteCode 邀请码
* @return 用户信息
*/
Users queryByInviteCode(@Param("inviteCode") String inviteCode);
/**
* 通过用户等级,获取该等级用户列表
*
* @param userLevel 用户等级
* @return 等级用户列表
*/
List<Users> getByLevel(@Param("userLevel") Integer userLevel);
/**
* @param
* @return
*/
Users biInvitedCode1(@Param("inviteCode") String inviteCode);
/**
* 用户邀请码查询用户数据
*
* @param inviteCode
* @return
*/
Users InvitedCode2(@Param("inviteCode") String inviteCode);
/**
* 根据用户的推荐人邀请码 查询上级用户的id
*
* @param beInvitedCode
* @return
*/
String getUserByIntiveCode(String beInvitedCode);
String getUserIdByIntiveCode(String outerUserId);
/**
* 获取所有的空投用户
* 且注册时间为一月之前
*
* @return
*/
List<Users> getAerialDeliveryUserBeforOneMonth(@Param("before") String before,
@Param("now") String now);
/**
* 随机获取一条小于当前id的用户 即: 比当前用户早注册的用户
*
* @param id
* @return
*/
Users randOneGetUserByUserId(Integer id);
/**
* 根据邀请码获取所有的下级用户
*
* @param userId
* @return
*/
List<Users> getListByIntvitedCode(String userId);
/**
* 根据当前用户的推荐人邀请码获取推荐人的用户信息(上级用户信息)
*
* @param beInvitedCode
* @return
*/
Users getuserByBeInvitedCode(String beInvitedCode);
/**
* 获取在团队中处于同一位置的用户集合
*
* @param beInvitedCode
* @return
*/
List<Users> getListUserByBeInvitedCode(String beInvitedCode);
/**
* 通过邀请码获取用户信息
*
* @param inviteCode
* @return
*/
Users getUserByInviteCode(String inviteCode);
/**
* 根据用户的userid查询用户对象
*
* @param userId
* @return
*/
Users getUserByUserId(String userId);
/**
* 分页查询所有用户信息
*
* @param map
* @return
*/
List<Users> getUserList(Map<String, Object> map);
/**
* 统计用户总记录数
*
* @param map 入参
* @return 结果
*/
int countUser(Map<String, Object> map);
}
......@@ -4,24 +4,41 @@
<mapper namespace="cn.wisenergy.mapper.UsersMapper">
<resultMap id="userMap" type="cn.wisenergy.model.app.Users">
<id column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="parent_id" property="parentId"/>
<result column="path" property="path"/>
<result column="rank" property="rank"/>
<result column="country_code" property="countryCode"/>
<result column="phone" property="phone"/>
<result column="password" property="password"/>
<result column="head_image" property="headImage"/>
<result column="user_level" property="userLevel"/>
<result column="cross_border_line" property="crossBorderLine"/>
<result column="id_card_number" property="idCardNumber"/>
<result column="fans_nickname" property="fansNickname"/>
<result column="fans_id" property="fansId"/>
<result column="invite_code" property="inviteCode"/>
<result column="be_invited_code" property="beInvitedCode"/>
<result column="customer_service_id" property="customerServiceId"/>
<result column="frozen" property="frozen"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="fund_pass" property="fundPass"/>
<result column="nickname" property="nickname"/>
<result column="avatar" property="avatar"/>
<result column="invited_code" property="invitedCode"/>
<result column="token" property="token"/>
<result column="hash" property="hash"/>
<result column="level" property="level"/>
<result column="now_level" property="nowLevel"/>
<result column="grade" property="grade"/>
<result column="status" property="status"/>
<result column="fund_status" property="fundStatus"/>
<result column="active" property="active"/>
<result column="note" property="note"/>
<result column="reg_time" property="regTime"/>
<result column="reg_ip" property="regIp"/>
<result column="reg_address" property="regAddress"/>
<result column="did" property="did"/>
<result column="read_time" property="readTime"/>
<result column="start_at" property="startAt"/>
<result column="expire_at" property="expireAt"/>
<result column="proxy" property="proxy"/>
<result column="is_work" property="isWork"/>
<result column="work_at" property="workAt"/>
<result column="created_at" property="createdAt"/>
<result column="updated_at" property="updatedAt"/>
</resultMap>
<sql id="table">
user_info
users
</sql>
<sql id="cols_all">
......@@ -30,45 +47,83 @@
</sql>
<sql id="cols_exclude_id">
user_id,password,head_image,user_level,cross_border_line,id_card_number,fans_nickname,fans_id, invite_code,
be_invited_code,customer_service_id,create_time,update_time
parent_id,path,rank,country_code,phone,password,fund_pass,nickname, avatar,invited_code,token,hash,`level`,now_level,
grade,status,fund_status,active,note,reg_time,reg_ip,reg_address,did,read_time,start_at,expire_at,proxy,is_work,
work_at,created_at,updated_at
</sql>
<sql id="vals">
#{userId},#{password},#{headImage},#{userLevel},#{crossBorderLine},#{idCardNumber},#{fansNickname},#{fansId},#{inviteCode},
#{beInvitedCode},#{customerServiceId},now(),now()
#{parentId},#{path},#{rank},#{countryCode},#{phone},#{password},#{fundPass},#{nickname},#{avatar},#{inviteCode},
#{token},#{hash},#{level},#{nowLevel},#{grade},#{status},#{fundStatus},#{active},#{note},#{regTime},#{regIp},
#{regAddress},#{did},#{readTime},#{startAt},#{expireAt},#{proxy},#{isWork},#{workAt},now(),now()
</sql>
<sql id="updateCondition">
<if test="userId != null">user_id = #{userId},</if>
<if test="password != null">password =#{password},</if>
<if test="headImage != null">head_image =#{headImage},</if>
<if test="userLevel != null">user_level =#{userLevel},</if>
<if test="crossBorderLine != null">cross_border_line =#{crossBorderLine},</if>
<if test="idCardNumber != null">id_card_number = #{idCardNumber},</if>
<if test="fansNickname != null">fans_nickname =#{fansNickname},</if>
<if test="fansId != null">fans_id =#{fansId},</if>
<if test="inviteCode != null">invite_code =#{inviteCode},</if>
<if test="beInvitedCode != null">be_invited_code = #{beInvitedCode},</if>
<if test="customerServiceId != null">customer_service_id = #{customerServiceId},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="path != null">path =#{path},</if>
<if test="rank != null">rank =#{rank},</if>
<if test="countryCode != null">country_code =#{countryCode},</if>
<if test="phone != null">phone =#{phone},</if>
<if test="password != null">password = #{password},</if>
<if test="fundPass != null">fund_pass =#{fundPass},</if>
<if test="nickname != null">nickname =#{nickname},</if>
<if test="avatar != null">avatar =#{avatar},</if>
<if test="inviteCode != null">invited_code = #{inviteCode},</if>
<if test="token != null">token = #{token},</if>
<if test="hash != null">hash =#{hash},</if>
<if test="level != null">`level` =#{level},</if>
<if test="nowLevel != null">now_level =#{nowLevel},</if>
<if test="grade != null">grade =#{grade},</if>
<if test="status != null">status = #{status},</if>
<if test="fundStatus != null">fund_status =#{fundStatus},</if>
<if test="active != null">active =#{active},</if>
<if test="note != null">note =#{note},</if>
<if test="regTime != null">reg_time = #{regTime},</if>
<if test="regIp != null">reg_ip = #{regIp},</if>
<if test="regAddress != null">reg_address =#{regAddress},</if>
<if test="did != null">did = #{did},</if>
<if test="readTime != null">read_time =#{readTime},</if>
<if test="startAt != null">start_at =#{startAt},</if>
<if test="expireAt != null">expire_at =#{expireAt},</if>
<if test="proxy != null">proxy = #{proxy},</if>
<if test="isWork != null">is_work = #{isWork},</if>
<if test="workAt != null">work_at = #{workAt},</if>
update_time =now()
</sql>
<sql id="criteria">
<if test="id != null">id = #{id}</if>
<if test="userId != null">and user_id = #{userId}</if>
<if test="password != null">and password =#{password}</if>
<if test="headImage != null">and head_image =#{headImage}</if>
<if test="userLevel != null">and user_level =#{userLevel}</if>
<if test="crossBorderLine != null">and cross_border_line =#{crossBorderLine}</if>
<if test="idCardNumber != null">and id_card_number = #{idCardNumber}</if>
<if test="fansNickname != null">and fans_nickname =#{fansNickname}</if>
<if test="fansId != null">and fans_id =#{fansId}</if>
<if test="inviteCode != null">and invite_code =#{inviteCode}</if>
<if test="beInvitedCode != null">and be_invited_code = #{beInvitedCode}</if>
<if test="customerServiceId != null">and customer_service_id = #{customerServiceId}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
<if test="parentId != null">and parent_id = #{parentId}</if>
<if test="path != null">and path =#{path}</if>
<if test="rank != null">and rank =#{rank}</if>
<if test="countryCode != null">and country_code =#{countryCode}</if>
<if test="phone != null">and phone =#{phone}</if>
<if test="password != null">and password = #{password}</if>
<if test="fundPass != null">and fund_pass =#{fundPass}</if>
<if test="nickname != null">and nickname =#{nickname}</if>
<if test="avatar != null">and avatar =#{avatar}</if>
<if test="inviteCode != null">and invited_code = #{inviteCode}</if>
<if test="token != null">and token = #{token}</if>
<if test="hash != null">and hash =#{hash}</if>
<if test="level != null">and `level` =#{level}</if>
<if test="nowLevel != null">and now_level =#{nowLevel}</if>
<if test="grade != null">and grade =#{grade}</if>
<if test="status != null">and status = #{status}</if>
<if test="fundStatus != null">and fund_status =#{fundStatus}</if>
<if test="active != null">and active =#{active}</if>
<if test="note != null">and note =#{note}</if>
<if test="regTime != null">and reg_time = #{regTime}</if>
<if test="regIp != null">and reg_ip = #{regIp}</if>
<if test="regAddress != null">and reg_address =#{regAddress}</if>
<if test="did != null">and did = #{did}</if>
<if test="readTime != null">and read_time =#{readTime}</if>
<if test="startAt != null">and start_at =#{startAt}</if>
<if test="expireAt != null">and expire_at =#{expireAt}</if>
<if test="proxy != null">and proxy = #{proxy}</if>
<if test="isWork != null">and is_work = #{isWork}</if>
<if test="workAt != null">and work_at = #{workAt}</if>
<if test="createdAt != null">and created_at &gt;= #{createdAt}</if>
<if test="updatedAt != null">and #{updatedAt} &gt;= updated_at</if>
</sql>
......@@ -98,367 +153,4 @@
where id = #{id}
</delete>
<select id="getList" resultMap="userMap" parameterType="map">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
be_invited_code=1
</where>
order by create_time desc
</select>
<select id="getUserById" resultType="cn.wisenergy.model.app.Users" parameterType="java.lang.Long">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
id=#{id}
</where>
</select>
<select id="getByUserId" resultType="cn.wisenergy.model.app.Users" parameterType="string">
select
id,user_id,password,head_image,user_level,cross_border_line,id_card_number,fans_nickname,fans_id, invite_code,
be_invited_code,customer_service_id,create_time,update_time
from
user_info
<where>
user_id=#{userId}
</where>
</select>
<select id="getById" resultType="java.lang.Integer" parameterType="string">
select
userId
from
user_info
<where>
user_id=#{userId}
</where>
</select>
<select id="ByUserId" resultType="java.lang.Integer">
select
id
from
user_info
<where>
user_id=#{userId}
</where>
</select>
<select id="findAllNotZeroUser" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
user_level !=0
</where>
</select>
<!--查询用户-->
<select id="findByName" resultType="cn.wisenergy.model.app.Users">
select * from User where user_id = #{userId}
</select>
<!--查询密码-->
<select id="findPswByName" resultType="String">
select password from users where user_id = #{userId}
</select>
<select id="getByBeInvitedCode" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
invite_code = #{beInvitedCode}
</where>
</select>
<select id="getAllGoldUser" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
user_level >3
</where>
</select>
<!--用户注册-->
<insert id="insertbyint">
insert into user_info(user_id,invite_code,be_invited_code,user_level,head_image,frozen) value
(#{userId},#{inviteCode},#{beInvitedCode},#{userLevel},#{headImage},#{frozen})
</insert>
<insert id="save">
insert into user_info(user_id,be_invited_code) value (#{userId},#{beInvitedCode})
</insert>
<select id="queryUsersByPhone" resultType="cn.wisenergy.model.app.Users">
select
<include refid="vals"/>
from
<include refid="table"/>
<where>
user_id=#{userId}
</where>
</select>
<!--根据用户的推荐人邀请码比对推荐人的本人邀请码,查询推荐人的用户ID-->
<select id="inviteCodeBeInvitedCode" resultType="java.lang.Integer">
select
user_id
from
<include refid="table"/>
<where>
invite_code=#{beInvitedCode}
</where>
</select>
<!--根据用户的推荐人邀请码比对推荐人的本人邀请码,查询推荐人的用户ID-->
<select id="beInvitedCode1" resultType="java.lang.Integer">
select
id
from
<include refid="table"/>
<where>
invite_code=#{beInvitedCode}
</where>
</select>
<select id="InvitedCode2" resultType="cn.wisenergy.model.app.Users" parameterType="string">
select
*
from
user_info
<where>
invite_code=#{inviteCode}
</where>
</select>
<select id="getuserIdById" resultType="java.lang.Integer">
select
id
from
user_info
<where>
user_id=#{userId}
</where>
</select>
<select id="BYQMById" resultType="String">
select
be_invited_code
from
<include refid="table"/>
<where>
user_id=#{userId}
</where>
</select>
<update id="edit1">
update
user_info
<set>
<if test="userLevel != null">user_level =#{userLevel},</if>
<if test="inviteCode != null">invite_code =#{inviteCode},</if>
create_time =now(),
update_time =now()
</set>
<where>
user_id = #{userId}
</where>
</update>
<!--分页查询所有用户信息 -->
<select id="getUsersListByMap" resultType="cn.wisenergy.model.app.Users" parameterType="java.util.Map">
select id as id,
user_id as userId,
password as password,
user_level as userLevel,
cross_border_line as crossBorderLine,
id_card_number as idCardNumber,
fans_nickname as fansNickname,
invite_code as inviteCode,
be_invited_code as beInvitedCode,
create_time as createTime,
update_time as updateTime
from user_info
<trim prefix="where" prefixOverrides="and | or">
<if test="id != null">
and id=#{id}
</if>
<if test="account != null and account!=''">
and userId=#{userId}
</if>
<if test="password != null and password!=''">
and password=#{password}
</if>
<if test="salt != null and salt!=''">
and userLevel=#{userLevel}
</if>
<if test="sex != null">
and idCardNumber=#{idCardNumber}
</if>
<if test="isAuthentication != null">
and fansNickname=#{fansNickname}
</if>
<if test="name != null and name!=''">
and inviteCode=#{inviteCode}
</if>
<if test="cardNo != null and cardNo!=''">
and beInvitedCode=#{beInvitedCode}
</if>
<if test="null!=creatdTime">
and creatdTime=#{creatdTime}
</if>
<if test="null!=updatedTime">
and updatedTime=#{updatedTime}
</if>
</trim>
<if test="beginPos != null and pageSize != null ">
limit #{beginPos},#{pageSize}
</if>
</select>
<!-- 获取当前用户的所有直接推荐人-->
<select id="getByInviteCode" resultType="cn.wisenergy.model.app.Users" parameterType="string">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
be_invited_code=#{inviteCode}
and user_level=#{userLevel}
</where>
</select>
<select id="queryByInviteCode" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
invite_code=#{inviteCode}
</where>
</select>
<select id="getByLevel" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
user_level=#{userLevel}
</where>
</select>
<select id="getUserByIntiveCode" parameterType="string" resultType="string">
select user_id
from
<include refid="table"/>
where
invite_code = #{beInvitedCode}
</select>
<select id="getUserIdByIntiveCode" resultType="string" parameterType="string">
select user_id
from
<include refid="table"/>
where
invite_code = #{outerUserId}
</select>
<select id="getAerialDeliveryUserBeforOneMonth" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
where
be_invited_code = '1'
and DATE_FORMAT(create_time,'%Y-%m-%d')
BETWEEN #{before} AND #{now}
</select>
<select id="randOneGetUserByUserId" resultType="cn.wisenergy.model.app.Users">
SELECT
<include refid="cols_all"/>
FROM
<include refid="table"/>
WHERE id &lt; #{id}
ORDER BY RAND() LIMIT 1
</select>
<select id="getListByIntvitedCode" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
where be_invited_code = #{intiveCode}
</select>
<select id="getuserByBeInvitedCode" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
where
invite_code = #{be_invited_code}
</select>
<select id="getListUserByBeInvitedCode" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
where
be_invited_code = #{be_invited_code}
</select>
<select id="getUserByInviteCode" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
where
invite_code = #{inviteCode}
</select>
<select id="getUserByUserId" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
where
user_id = #{userId}
</select>
<select id="getUserList" resultType="cn.wisenergy.model.app.Users">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
1=1
<if test="userId != null and userId != ''">
and user_id = #{userId}
</if>
<if test="queryTime != null and queryTime != ''">
and (YEAR(create_time) = YEAR(#{queryTime})
AND MONTH(create_time) =MONTH(#{queryTime})
AND DAY(create_time)=DAY(#{queryTime}))
</if>
</where>
order by create_time desc
limit #{startNum},#{endNum}
</select>
<select id="countUser" resultType="java.lang.Integer">
select count(1)
from
user_info
</select>
</mapper>
package cn.wisenergy.model.app;
import lombok.Data;
/**
* @author 86187
*/
@Data
public class UserRecharge {
private Long id;
/**
* 会员id
*/
private Integer userId;
/**
* 币种id
*/
private Integer currencyId;
}
......@@ -19,20 +19,9 @@ public interface UserService {
* @param userId 用户id
* @return 用户信息
*/
Users getById(String userId);
Users getById(Integer userId);
R<Integer> getById1(String userId);
Users getUserById(Long id);
/**
* 获取用户信息
*
* @param userId 用户id
* @return 用户信息
*/
Users getByUserId(String userId);
/**
* 根据手机号查询用户
......@@ -44,23 +33,4 @@ public interface UserService {
*/
Users queryUsersByOpenId(String openId);
/**
* 用户登出
*
* @param token
* @return
*/
int logout(String token);
Integer getUserIdById(String userId);
/**
* 设置用户头像
*
* @param userId 用户id
* @param headImage 头像图片地址
* @return true or false
*/
R<Boolean> setHeadImage(String userId, String headImage);
}
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.*;
import cn.wisenergy.mapper.*;
import cn.wisenergy.model.app.*;
import cn.wisenergy.service.app.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -23,91 +21,18 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, Users> implements
@Autowired
private UsersMapper usersMapper;
@Autowired
private RedisUtils redisUtils;
private static final String INVITE_CODE = "1";
@Override
public Users getById(String userId) {
return usersMapper.getByUserId(userId);
}
@Override
public R<Integer> getById1(String userId) {
return R.ok(usersMapper.ByUserId(userId));
}
@Override
public Users getUserById(Long id) {
return this.usersMapper.getUserById(id);
}
@Override
public Users getByUserId(String userId) {
return usersMapper.getByUserId(userId);
public Users getById(Integer userId) {
return null;
}
@Override
public Users queryUsersByPhone(String userId) {
//查询数据库,看看是否存在该用户
return usersMapper.getByUserId(userId);
}
@Override
public Users queryUsersByOpenId(String id) {
return null;
}
@Override
public Integer getUserIdById(String userId) {
public Users queryUsersByOpenId(String id) {
return null;
}
@Override
public R<Boolean> setHeadImage(String userId, String headImage) {
log.info("shop-mall[]UserServiceImpl[]setHeadImage[]input.param.userId,headImage:" + userId, headImage);
if (StringUtils.isBlank(userId) || StringUtils.isBlank(headImage)) {
return R.error("入参不能为空!");
}
//获取用户信息
Users users = usersMapper.getByUserId(userId);
if (null == users) {
return R.error("用户信息不存在!");
}
//添加头像
users.setHeadImage(headImage);
int count = usersMapper.edit(users);
if (count == 0) {
return R.error("设置头像失败!");
}
return R.ok(0, true);
}
/**
* 用户登出
*
* @param token
* @return
*/
@Override
public int logout(String token) {
int succ = 0;
String key = RedisKeyUtils.formatKeyWithPrefix(Constants.Redis.PREFIX_TOKEN, token);
redisUtils.delete(key);
if (redisUtils.getValue(key) == null) {
succ = 1;
}
return succ;
}
}
......@@ -10,6 +10,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* 配置netty启动
* @author 86187
*/
@EnableCaching
@SpringBootApplication(exclude = {MultipartAutoConfiguration.class})
......
......@@ -41,9 +41,9 @@ public class UserController extends BaseController {
private RedisUtils redisUtils;
@ApiOperation(value = "获取用户信息", notes = "获取用户信息", httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "int")
@GetMapping("/user/getByUserId")
public Users getByUserId(String userId) {
public Users getByUserId(Integer userId) {
return userService.getById(userId);
}
......@@ -54,13 +54,13 @@ public class UserController extends BaseController {
*/
@ApiOperation(value = "获取token接口", notes = "获取token接口", httpMethod = "POST")
@PostMapping(value = "/user/login")
public R<String> login(String id) {
public R<String> login(Integer id) {
if (null == id) {
return R.error("入参为空!");
}
//用户信息
Users users = userService.getByUserId(id);
Users users = userService.getById(id);
// 创建token
String token = jwtUtil.generateToken(users);
......@@ -68,20 +68,4 @@ public class UserController extends BaseController {
redisTemplate.opsForValue().set(RedisConsts.JWT_ACCESS_TOKEN + token, token);
return R.ok(token);
}
@ApiOperation(value = "设置头像", notes = "设置头像", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String"),
@ApiImplicitParam(name = "headImage", value = "头像Url", dataType = "String")
})
@PostMapping("/user/setHeadImage")
public R<Boolean> setHeadImage(String userId, String headImage) {
log.info("shop-mall[]UserController[]setHeadImage[]input.param.userId,headImage:" + userId, headImage);
if (StringUtils.isBlank(userId) || StringUtils.isBlank(headImage)) {
return R.error("入参不能为空!");
}
return userService.setHeadImage(userId, headImage);
}
}
package cn.wisenergy.web.aspect;
import cn.wisenergy.common.annotation.DataAuth;
import cn.wisenergy.common.constant.CommonConstants;
import cn.wisenergy.common.enums.RespCodeEnum;
import cn.wisenergy.common.utils.exception.Result;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.Map;
/**
* 数据权限,切面处理类
*/
@Aspect
@Component
public class DataAuthAspect {
@Autowired
AccountService sysUserService;
@Pointcut("@annotation(cn.wisenergy.common.annotation.DataAuth)")
public void dataPointCut() {
}
@Around("dataPointCut()")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
MethodSignature signature = (MethodSignature) pjp.getSignature();
Method method = signature.getMethod();
// 获取方法上的注解
DataAuth dataAuth = method.getAnnotation(DataAuth.class);
if (dataAuth != null) {
// 获取注解值
String mapKey = dataAuth.value();
// 获取请求参数
Object[] args = pjp.getArgs();
for (Object obj : args) {
if (obj instanceof Map) {
Map<String, Object> map = (Map<String, Object>) obj;
// 获取当前用户
AccountInfo sysUser = (AccountInfo) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
// 超级管理员返回全量数据
if (!StringUtils.equals(sysUser.getId().toString(), CommonConstants.SUPER_ADMIN)) {
// 查询用户的数据权限信息,如果存在数据权限集合,将集合存入请求参数map中
// Set<String> dataAuthList = sysUserService.getUserDataAuth(sysUser);
// if (dataAuthList != null && !dataAuthList.isEmpty()) {
// map.put(mapKey, dataAuthList);
// }
}
return pjp.proceed();
}
}
}
}
Result result = new Result();
result.setResult(Result.RESULT_FLG.FAIL.getValue());
result.setErrorCode(RespCodeEnum.DATA_AUTH_UNAUTHORIZED.getCode());
result.setErrorMsg(RespCodeEnum.DATA_AUTH_UNAUTHORIZED.getMsg());
return result;
}
}
package cn.wisenergy.web.aspect;
import cn.wisenergy.common.utils.exception.Result;
import cn.wisenergy.common.utils.ip.IpUtils;
import com.alibaba.fastjson.JSON;
import org.apache.shiro.SecurityUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.Date;
/**
* 系统日志,切面处理类
*/
@Aspect
@Component
public class SysLogAspect {
// @Autowired
// private SysLogService sysLogService;
//
// @Pointcut("@annotation(cn.wisenergy.common.annotation.SysLog)")
// public void logPointCut() {
// }
//
// @Around("logPointCut()")
// public Object around(ProceedingJoinPoint point) throws Throwable {
// long beginTime = System.currentTimeMillis();
// //执行方法
// Object result = point.proceed();
// //执行时长(毫秒)
// long time = System.currentTimeMillis() - beginTime;
//
// //保存日志
// saveSysLog(point, time, result);
//
// return result;
// }
//
// private void saveSysLog(ProceedingJoinPoint joinPoint, long time,Object result) {
// MethodSignature signature = (MethodSignature) joinPoint.getSignature();
// Method method = signature.getMethod();
//
// SysLogEntity sysLog = new SysLogEntity();
// cn.wisenergy.common.annotation.SysLog syslog = method.getAnnotation(cn.wisenergy.common.annotation.SysLog.class);
// if(syslog != null){
// //注解上的描述
// sysLog.setOperation(syslog.value());
// }
//
// //请求的方法名
// String className = joinPoint.getTarget().getClass().getName();
// String methodName = signature.getName();
// sysLog.setMethod(className + "." + methodName + "()");
//
// //请求的参数
// Object[] args = joinPoint.getArgs();
// String params = JSON.toJSONString(args);
// sysLog.setParams(params);
//
// //返回值
// Result<?> r= (Result<?>) result;
// if("success".equals(r.getResult())) {
// sysLog.setState("成功");
// }else {
// sysLog.setState("失败");
// }
// //获取request
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// //设置IP地址
// sysLog.setIp(IpUtils.getIpAddr(request));
// //用户名
// SysUserEntity principal = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
// String username =principal.getUsername();
// sysLog.setUsername(username);
// sysLog.setTime(time);
// sysLog.setCreateDate(new Date());
// //保存系统日志
// try {
// sysLogService.save(sysLog);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
}
package cn.wisenergy.web.aspect;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
* AOP日志
* @author 86187
*/
@Aspect
@Component
@Slf4j
public class WebLogAspect {
/**
* 两个..代表所有子目录,最后括号里的两个..代表所有参数
*/
@Pointcut("execution( * cn.wisenergy.web.admin.controller..*.*(..))")
public void logPointCut() {
}
@Before("logPointCut()")
public void doBefore(JoinPoint joinPoint) {
// 接收到请求,记录请求内容
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
// 记录下请求内容
log.info(" ___________________________________________________________");
log.info("| 请求地址 : {}", request.getRequestURL().toString());
log.info("| 请求方式 : {}", request.getMethod());
// 获取执行的方法全路径
String methodName = joinPoint.getSignature().getName();
log.info("| 执行方法 : {}.{}", joinPoint.getSignature().getDeclaringTypeName(), methodName);
}
/**
* returning的值和doAfterReturning的参数名一致
*/
@AfterReturning(returning = "ret", pointcut = "logPointCut()")
public void doAfterReturning(Object ret) {
// 处理完请求,返回内容
log.info("| 返回值 : {}", JSON.toJSONString(ret));
log.info(" ———————————————————————————————————————————");
}
@Around("logPointCut()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
long startTime = System.currentTimeMillis();
// ob 为方法的返回值
Object ob = pjp.proceed();
log.info("| 耗时 : {}", (System.currentTimeMillis() - startTime));
return ob;
}
}
......@@ -51,7 +51,7 @@ public class AuthRealm extends AuthorizingRealm {
*/
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
AccountInfo user = (AccountInfo) principals.getPrimaryPrincipal();
Users user = (Users) principals.getPrimaryPrincipal();
String userId = user.getId().toString();
//用户权限列表
// Set<String> permsSet = sysUserService.queryAllPerms(userId);
......@@ -98,7 +98,7 @@ public class AuthRealm extends AuthorizingRealm {
throw new IncorrectCredentialsException(RespCodeEnum.TOKEN_IS_NOT_TIMEOUT.getMsg());
}*/
//查询用户信息
Users users = authUserService.getByUserId(usersEntity.getUserId());
Users users = authUserService.getById(usersEntity.getId());
// 判断请求token与redis中是否相同,如果token被刷新,则不判断
if (!refreshFlag && !StringUtils.equals(accessToken, redisToken)) {
throw new IncorrectCredentialsException(RespCodeEnum.NO_AUTH_REQUEST.getMsg());
......
......@@ -16,7 +16,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://8.140.102.52:3306/shop-mall?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
url: jdbc:mysql://8.140.102.52:3306/yashi?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root
password: adm4HYservice$
initial-size: 10
......
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