Commit f60edee6 authored by licc's avatar licc

代码提交

parent 0d5963f3
package cn.wisenergy.mapper;
import cn.wisenergy.model.app.UserLimit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface UserLimitMapper extends BaseMapper<UserLimit> {
UserLimit add(UserLimit userLimit);
int edit(UserLimit userLimit);
}
package cn.wisenergy.mapper;
import cn.wisenergy.model.app.UserVolunteer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
public interface UserVolunteerMapper extends BaseMapper<UserVolunteer> {
UserVolunteer add(UserVolunteer userVolunteer);
int edit(UserVolunteer userVolunteer);
int delById(@Param("id") Integer id);
}
......@@ -32,4 +32,6 @@ public interface UsersMapper extends BaseMapper<UserInfo> {
* @return 删除是否成功
*/
int delById(@Param("id") Integer id);
int countByPhoneAnsUserId(@Param("phone") String phone,@Param("userId") Integer userId);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.mapper.UserLimitMapper">
<resultMap id="userMap" type="cn.wisenergy.model.app.UserLimit">
<id column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="total_limit" property="totalLimit"/>
<result column="use_limit" property="useLimit"/>
<result column="usable_limit" property="usableLimit"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="table">
user
</sql>
<sql id="cols_all">
id,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
user_id,total_limit, use_limit,usable_limit,create_time,update_time
</sql>
<sql id="vals">
#{userId},#{totalLimit},#{useLimit},#{usableLimit},now(),now()
</sql>
<sql id="updateCondition">
<if test="userId != null">user_id = #{userId},</if>
<if test="totalLimit != null">total_limit =#{totalLimit},</if>
<if test="useLimit != null">use_limit =#{useLimit},</if>
<if test="usableLimit != null">usable_limit =#{usableLimit},</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="totalLimit != null">and total_limit =#{totalLimit}</if>
<if test="useLimit != null">and use_limit =#{useLimit}</if>
<if test="usableLimit != null">and usable_limit =#{usableLimit}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
</sql>
<insert id="add" parameterType="cn.wisenergy.model.app.UserLimit" keyProperty="id" useGeneratedKeys="true">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
value(
<include refid="vals"/>
)
</insert>
<update id="edit" parameterType="cn.wisenergy.model.app.UserLimit">
UPDATE
<include refid="table"/>
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.mapper.UserVolunteerMapper">
<resultMap id="userMap" type="cn.wisenergy.model.app.UserVolunteer">
<id column="id" property="id"/>
<result column="scheme_record_id" property="schemeRecordId"/>
<result column="user_id" property="userId"/>
<result column="volunteer_id" property="volunteerId"/>
</resultMap>
<sql id="table">
user
</sql>
<sql id="cols_all">
id,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
scheme_record_id,user_id, volunteer_id
</sql>
<sql id="vals">
#{schemeRecordId},#{userId},#{volunteerId}
</sql>
<sql id="updateCondition">
<if test="schemeRecordId != null">scheme_record_id = #{schemeRecordId},</if>
<if test="userId != null">user_id =#{userId},</if>
<if test="volunteerId != null">volunteer_id =#{volunteerId},</if>
</sql>
<sql id="criteria">
<if test="id != null">id = #{id}</if>
<if test="schemeRecordId != null">and scheme_record_id = #{schemeRecordId}</if>
<if test="userId != null">and user_id =#{userId}</if>
<if test="volunteerId != null">and volunteer_id =#{volunteerId}</if>
</sql>
<insert id="add" parameterType="cn.wisenergy.model.app.UserVolunteer" keyProperty="id" useGeneratedKeys="true">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
value(
<include refid="vals"/>
)
</insert>
<update id="edit" parameterType="cn.wisenergy.model.app.UserVolunteer">
UPDATE
<include refid="table"/>
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
<delete id="delById" parameterType="java.lang.Integer">
delete from
<include refid="table"/>
where id = #{id}
</delete>
</mapper>
......@@ -93,4 +93,11 @@
where id = #{id}
</delete>
<select id="countByPhoneAnsUserId" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM
<include refid="table"/>
WHERE phone=#{phone} and id !=#{userId} and is_delete=0
</select>
</mapper>
package cn.wisenergy.model.app;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
*@ Description: 充值记录实体类
*@ Author : 86187
*@ Date : 2021/1/8 14:48
*/
@Data
@ApiModel(value = "PayRecord")
public class PayRecord implements Serializable {
private static final long serialVersionUID = -7865361068703566832L;
/**
*
*/
@ApiModelProperty(value = "",name = "")
private Integer id;
/**
*
*/
@ApiModelProperty(value = "",name = "")
private Integer type;
/**
*
*/
@ApiModelProperty(value = "",name = "")
private String cardCode;
/**
*
*/
@ApiModelProperty(value = "",name = "")
private Integer userId;
/**
*
*/
@ApiModelProperty(value = "",name = "")
private String money;
/**
*
*/
@ApiModelProperty(value = "",name = "")
private Integer result;
/**
*
*/
@ApiModelProperty(value = "",name = "")
private Integer limit;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间",name = "createTime")
private Date createTime;
/**
* 更行时间
*/
@ApiModelProperty(value = "更行时间",name = "updateTime")
private Date updateTime;
}
package cn.wisenergy.model.app;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @ Description: 用户查询次数实体类
* @ Author : 86187
* @ Date : 2021/1/8 17:39
*/
@Data
@ApiModel(value = "UserLimit")
public class UserLimit implements Serializable {
private static final long serialVersionUID = -4567717561062839767L;
/**
* 主键id
*/
@ApiModelProperty(value = "主键id", name = "id")
private Integer id;
/**
* 用户id
*/
@ApiModelProperty(value = "用户id", name = "userId")
private Integer userId;
/**
* 总次数
*/
@ApiModelProperty(value = "总次数", name = "totalLimit")
private Integer totalLimit;
/**
* 已使用次数
*/
@ApiModelProperty(value = "已使用次数", name = "useLimit")
private Integer useLimit;
/**
* 可使用次数
*/
@ApiModelProperty(value = "可使用次数", name = "usableLimit")
private Integer usableLimit;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间", name = "createTime")
private Date createTime;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间", name = "updateTime")
private Date updateTime;
}
package cn.wisenergy.model.app;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
*@ Description: 用户方案记录实体类
*@ Author : 86187
*@ Date : 2021/1/8 17:24
*/
@Data
@ApiModel(value = "UserVolunteer")
public class UserVolunteer implements Serializable {
private static final long serialVersionUID = -2103279712102307306L;
/**
* id
*/
@ApiModelProperty(value = "id",name = "id")
private Integer id;
/**
* 方案记录id
*/
@ApiModelProperty(value = "方案记录id",name = "schemeRecordId")
private Integer schemeRecordId;
/**
* 用户id
*/
@ApiModelProperty(value = "用户id",name = "userId")
private Integer userId;
/**
* 志愿id
*/
@ApiModelProperty(value = "志愿id",name = "volunteerId")
private Integer volunteerId;
}
......@@ -32,6 +32,12 @@
<artifactId>artemis-http-client</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>20.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
......
package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.Volunteer;
import java.util.List;
public interface VolunteerService {
/**
* 批量添加志愿
*
* @param list 志愿列表信息
* @return true 成功 false 失败
*/
R<Boolean> batchAdd(List<Volunteer> list);
}
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.Md5Util;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.UsersMapper;
import cn.wisenergy.model.app.UserInfo;
import cn.wisenergy.service.app.UserLoginService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*@ Description: 用户登录相关接口实现
*@ Author : 86187
*@ Date : 2021/1/7 14:22
*/
* @ Description: 用户登录相关接口实现
* @ Author : 86187
* @ Date : 2021/1/7 14:22
*/
@Service
@Slf4j
public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> implements UserLoginService {
@Autowired
private UsersMapper usersMapper;
@Override
public R<Boolean> register(String phone, String password) {
return null;
log.info("volunteer-service[]UserLoginServiceImpl[]register[]input.param.phone,password:" + phone, password);
if (StringUtils.isBlank(phone) || StringUtils.isBlank(password)) {
return R.error("入参为空!");
}
//1.检查号码是否重复
Integer userId = null;
Boolean bool = checkPhone(phone, userId);
if (!bool) {
return R.error("该电话号码" + phone + "已被使用!");
}
//2、给密码加密 加密规则,电话号码+明文密码
String secret = Md5Util.digestMD5(phone + password);
//3、添加用户信息
UserInfo userInfo = new UserInfo();
userInfo.setPhone(phone);
userInfo.setPassword(secret);
UserInfo user = usersMapper.add(userInfo);
if (null == user) {
return R.ok(1, false);
}
return R.ok(0, true);
}
@Override
......@@ -28,6 +61,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
@Override
public R<Boolean> login(String code, String phone) {
return null;
}
......@@ -50,4 +84,30 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
public R<Boolean> notePassword(Integer code, String phone) {
return null;
}
private Boolean checkPhone(String phone, Integer userId) {
//判断是注册还是编辑
//1、注册-新增
if (null == userId) {
//根据电话号码查询用户
QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("phone", phone);
queryWrapper.eq("is_delete", 0);
UserInfo userInfo = usersMapper.selectOne(queryWrapper);
if (null != userInfo) {
return false;
}
}
//2、编辑
if (null != userId) {
//根据电话号码和用户id,统计号码是否重复
int count = usersMapper.countByPhoneAnsUserId(phone, userId);
if (count > 0) {
return false;
}
}
return true;
}
}
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.constant.CommonAttributes;
import cn.wisenergy.common.utils.Md5Util;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.UsersMapper;
import cn.wisenergy.model.app.UserInfo;
......
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.VolunteerMapper;
import cn.wisenergy.model.app.Volunteer;
import cn.wisenergy.service.app.VolunteerService;
......@@ -7,6 +8,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*@ Description: 志愿接口实现
*@ Author : 86187
......@@ -15,4 +18,8 @@ import org.springframework.stereotype.Service;
@Service
@Slf4j
public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer> implements VolunteerService {
@Override
public R<Boolean> batchAdd(List<Volunteer> list) {
return null;
}
}
......@@ -6,56 +6,16 @@ package cn.wisenergy.service.common;
* @ CreateDate : 2020/11/8 20:35
*/
public class Common {
/**
* 派单接口请求路径
*/
public static String SEND_ORDER_URL = "http://172.18.1.53:8066/schedule/info0001/create_4";
/**
* 接单接口请求路径
*/
public static String RECEIVE_ORDER_URL = "http://172.18.1.53:8066/schedule/info0001/update_by_next2";
//微信公众号平台开发相关
/**
* appId
* 注册标识
*/
public static String APP_ID = "wxf5cf916809cf5f05";
public static final String REGISTER="register";
/**
* AppSecret
*/
public static String APP_SECRET = "c28e62a7100fafc96ded07518e1630cf";
/**
* access_token_url
*/
public static String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token";
/**
* add_news_url
*/
public static String ADD_NEWS_URL = "https://api.weixin.qq.com/cgi-bin/material/add_news";
/**
* update_news_url
*/
public static String UPDATE_NEWS_URL = "https://api.weixin.qq.com/cgi-bin/material/update_news";
/**
* 微信公众号-添加永久素材
* add_material
*/
public static String ADD_MATERIAL = "https://api.weixin.qq.com/cgi-bin/material/add_material";
/**
* 微信公众号-获取永久素材
* add_material
* 编辑标识
*/
public static String GET_MATERIAL = "https://api.weixin.qq.com/cgi-bin/material/get_material";
public static final String LOGIN_EDIT="login_edit";
}
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