Commit 32c461c8 authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/dev' into dev

parents ac0a4c56 06655c46
......@@ -84,9 +84,10 @@ public class AuthController {
@RequestParam(value="mobilecode",defaultValue="")String mobilecode,
@RequestParam(value="password",defaultValue="")String password,
@RequestParam(value="code",defaultValue="")String code,
@RequestParam(value="channel",defaultValue="1")Integer channel)throws Exception{
@RequestParam(value="channel",defaultValue="1")Integer channel,
@RequestParam(value="registerSource",defaultValue="")String registerSource)throws Exception{
log.info(username+"----require register...");
JSONObject data=appAuthService.register(username,mobilecode,password,code,channel);
JSONObject data=appAuthService.register(username,mobilecode,password,code,channel,registerSource);
if(data!=null&&data.getInteger("status")== ResultCode.SUCCESS_CODE){
JwtAuthenticationRequest authenticationRequest=new JwtAuthenticationRequest();
authenticationRequest.setUsername(username);
......@@ -108,11 +109,12 @@ public class AuthController {
@RequestParam(value="type",defaultValue="0")Integer type,
@RequestParam(value="isQQ",defaultValue="0")Integer isQQ,
@RequestParam(value="code",defaultValue="")String code,
@RequestParam(value="channel",defaultValue="1")Integer channel
@RequestParam(value="channel",defaultValue="1")Integer channel,
@RequestParam(value="registerSource",defaultValue="")String registerSource
)throws Exception{
log.info(username+"----require wxregister...");
JSONObject data=appAuthService.wxregister( username, mobilecode, password, nickname,
headimgurl, openid, unionid,type,isQQ,code,channel);
headimgurl, openid, unionid,type,isQQ,code,channel,registerSource);
if(data!=null&&data.getInteger("status")== ResultCode.SUCCESS_CODE){
JSONObject result=data.getJSONObject("data");
if(result==null){
......
......@@ -35,7 +35,8 @@ public interface IUserService {
@RequestParam(value="mobilecode",defaultValue="")String mobilecode,
@RequestParam(value="password",defaultValue="")String password,
@RequestParam(value="code")String code,
@RequestParam(value="channel",defaultValue="1")Integer channel);
@RequestParam(value="channel",defaultValue="1")Integer channel,
@RequestParam(value="registerSource",defaultValue="")String registerSource);
@RequestMapping(value = "/api/app/user/wxregister", method = RequestMethod.POST)
public JSONObject wxregister(
@RequestParam(value="username")String username,@RequestParam(value="mobilecode")String mobilecode,
......@@ -43,7 +44,8 @@ public interface IUserService {
@RequestParam(value="headimgurl")String headimgurl,@RequestParam(value="openid")String openid,
@RequestParam(value="unionid")String unionid,@RequestParam(value="type")Integer type,
@RequestParam(value="isQQ")Integer isQQ,@RequestParam(value="code")String code,
@RequestParam(value="channel",defaultValue="1")Integer channel);
@RequestParam(value="channel",defaultValue="1")Integer channel,
@RequestParam(value="registerSource",defaultValue="")String registerSource);
@RequestMapping(value = "/api/app/user/checkBindWechat",method = RequestMethod.POST)
public JSONObject checkBindWechat( @RequestParam(value="username")String username);
@RequestMapping(value = "/api/app/user/wxlogin",method = RequestMethod.POST)
......
......@@ -11,8 +11,8 @@ public interface AuthService {
String refresh(String oldToken) throws Exception;
void validate(String token) throws Exception;
JSONObject sendsms(String username, Integer type, String pointList) throws Exception;
JSONObject register(String username, String mobilecode, String password,String code, Integer channel) throws Exception;
JSONObject wxregister( String username, String mobilecode, String password, String nickname, String headimgurl, String openid, String unionid, Integer type,Integer isQQ,String code, Integer channel) throws Exception;
JSONObject register(String username, String mobilecode, String password,String code,Integer channel,String registerSource) throws Exception;
JSONObject wxregister( String username, String mobilecode, String password, String nickname, String headimgurl, String openid, String unionid, Integer type,Integer isQQ,String code,Integer channel,String registerSource) throws Exception;
JSONObject checkBindWechat(String username) throws Exception;
JSONObject wxlogin(String openid,Integer isQQ,String code) throws Exception;
JSONObject tlogin(String username, String password,String mobilecode,Integer type,String code) throws Exception;
......
......@@ -72,13 +72,13 @@ public class AppAuthServiceImpl implements AuthService {
}
@Override
public JSONObject register(String username, String mobilecode, String password,String code, Integer channel) throws Exception {
return userService.register(username,mobilecode,password,code,channel);
public JSONObject register(String username, String mobilecode, String password,String code,Integer channel,String registerSource) throws Exception {
return userService.register(username,mobilecode,password,code,channel,registerSource);
}
@Override
public JSONObject wxregister(String username, String mobilecode, String password, String nickname, String headimgurl, String openid, String unionid, Integer type,Integer isQQ,String code, Integer channel) throws Exception {
return userService.wxregister(username,mobilecode,password,nickname,headimgurl,openid,unionid,type,isQQ,code,channel);
public JSONObject wxregister(String username, String mobilecode, String password, String nickname, String headimgurl, String openid, String unionid, Integer type,Integer isQQ,String code,Integer channel,String registerSource) throws Exception {
return userService.wxregister(username,mobilecode,password,nickname,headimgurl,openid,unionid,type,isQQ,code,channel,registerSource);
}
@Override
......
......@@ -69,13 +69,13 @@ public class AuthServiceImpl implements AuthService {
return userService.sendsms(username,type, pointList);
}
@Override
public JSONObject register(String username, String mobilecode, String password,String code,Integer channel) throws Exception {
return userService.register(username,mobilecode,password,code,channel);
public JSONObject register(String username, String mobilecode, String password,String code,Integer channel,String registerSource) throws Exception {
return userService.register(username,mobilecode,password,code,channel,registerSource);
}
@Override
public JSONObject wxregister(String username, String mobilecode, String password, String nickname, String headimgurl, String openid, String unionid, Integer type,Integer isQQ,String code,Integer channel) throws Exception {
return userService.wxregister(username,mobilecode,password,nickname,headimgurl,openid,unionid,type,isQQ,code,channel);
public JSONObject wxregister(String username, String mobilecode, String password, String nickname, String headimgurl, String openid, String unionid, Integer type,Integer isQQ,String code,Integer channel,String registerSource) throws Exception {
return userService.wxregister(username,mobilecode,password,nickname,headimgurl,openid,unionid,type,isQQ,code,channel,registerSource);
}
@Override
......
......@@ -75,6 +75,15 @@ public class AppUserManageDTO {
private String realName;
/**
* 注册来源
*/
private String registerSource;
/**
* 注册来源名称
*/
private String markName;
// /**
// * 接收前台时间范围
// */
......
package com.github.wxiaoqi.security.admin.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
......@@ -12,6 +14,8 @@ import javax.persistence.Table;
* 用户详情信息表
*/
@Table(name = "app_user_detail")
@AllArgsConstructor
@NoArgsConstructor
@Data
public class AppUserDetail {
@Id
......@@ -79,7 +83,13 @@ public class AppUserDetail {
@Column(name = "inviter_account")
private Integer inviterAccount;
@ApiModelProperty(value = "1-新人用户;2-未激活;3-激活")
@Column(name = "state")
private Integer state;
@ApiModelProperty(value = "1-新人用户;2-未激活;3-激活")
@Column(name = "state")
private Integer state;
@ApiModelProperty(value = "注册来源")
@Column(name = "register_source")
private String registerSource;
}
......@@ -21,6 +21,12 @@ public class AppUserManageVo {
@Column(name = "channel")
private String channel;
/**
* 注册来源
*/
@Column(name="register_source")
private String registerSource;
/**
* 是否是会员:0-不是;1-会员
*/
......@@ -186,4 +192,10 @@ public class AppUserManageVo {
* 上级手机号
*/
private String superiorMobileNumber;
/**
* 注册来源名称
*/
@Column(name = "mark_name")
private String markName;
}
......@@ -14,90 +14,95 @@ import lombok.NoArgsConstructor;
public class AppUserVo {
private Integer id;
//用户id
private Integer userid;
//imid
private Integer imUserid;
///账号(手机号)
private String username;
//微信openid
private String wxOpenid;
//微信unionid
private String unionid;
//qq
private String openid;
//状态:0-启用,1-禁用
private Integer status;
//身份证号
private String idNumber;
//实名认证状态:0-未认证,1-已认证
private Integer certificationStatus;
//会员
private Integer isMember;
//昵称
private String nickname;
private String wxNickname;
private String aliPayNickName;
private String qqNickname;
//真实姓名
private String realname;
//头像
private String headimgurl;
//邮箱
private String email;
//性别 0-女,1-男
private Integer sex;
//生日
private String birthday;
//个性签名
private String personSign;
//备注
private String remark;
//渠道来源;1-app;2-小程序
private Integer channel;
/**
* 省份编号
*/
private Integer provinceCode;
/**
* 市编号
*/
private Integer cityCode;
/**
* 创建ip
*/
private String crtHost;
/**
* 更新ip
*/
private String updHost;
@ApiModelProperty(value = "用户职位")
private Integer positionId;
@ApiModelProperty(value = "用户来源:0-自来,1-用户邀请")
private Integer source;
@ApiModelProperty(value = "邀请码")
private String code;
@ApiModelProperty(value = "邀请人id:")
private Integer inviterAccount;
@ApiModelProperty(value = "1-未激活;2-激活:")
private Integer state;
private Integer id;
//用户id
private Integer userid;
//imid
private Integer imUserid;
///账号(手机号)
private String username;
//微信openid
private String wxOpenid;
//微信unionid
private String unionid;
//qq
private String openid;
//状态:0-启用,1-禁用
private Integer status;
//身份证号
private String idNumber;
//实名认证状态:0-未认证,1-已认证
private Integer certificationStatus;
//会员
private Integer isMember;
//昵称
private String nickname;
private String wxNickname;
private String aliPayNickName;
private String qqNickname;
//真实姓名
private String realname;
//头像
private String headimgurl;
//邮箱
private String email;
//性别 0-女,1-男
private Integer sex;
//生日
private String birthday;
//个性签名
private String personSign;
//备注
private String remark;
//渠道来源;1-app;2-小程序
private Integer channel;
//注册来源
private String registerSource;
//注册来源名称
private String markName;
/**
* 省份编号
*/
private Integer provinceCode;
/**
* 市编号
*/
private Integer cityCode;
/**
* 创建ip
*/
private String crtHost;
/**
* 更新ip
*/
private String updHost;
@ApiModelProperty(value = "用户职位")
private Integer positionId;
@ApiModelProperty(value = "用户来源:0-自来,1-用户邀请")
private Integer source;
@ApiModelProperty(value = "邀请码")
private String code;
@ApiModelProperty(value = "邀请人id:")
private Integer inviterAccount;
@ApiModelProperty(value = "1-未激活;2-激活:")
private Integer state;
@ApiModelProperty(value = "支付宝授权返回的code")
private String aliCode;
private String aliCode;
@ApiModelProperty(value = "用户职位名称")
private String jobTitle;
@ApiModelProperty(value = "用户职位名称")
private String jobTitle;
@ApiModelProperty(value = "用户会员名称")
private String memberName;
@ApiModelProperty(value = "用户会员名称")
private String memberName;
}
......@@ -72,7 +72,7 @@ public class AppUsersManageController extends BaseController<AppUserManageBiz,Ap
User user = (User) objectRestResponse.getData();
if (user==null){
throw new BaseException("User error!");
}
}
if (ALL_PERMISSIONS.equals(user.getDataAll())) {
return ObjectRestResponse.succ(baseBiz.findAllByQuery(appUserManageDTO));
}
......
......@@ -89,12 +89,13 @@ public class AppUserRest {
@RequestParam(value="mobilecode",defaultValue="")String mobilecode,
@RequestParam(value="password",defaultValue="")String password,
@RequestParam(value="code",defaultValue="")String code,
@RequestParam(value="channel",defaultValue="1")Integer channel
@RequestParam(value="channel",defaultValue="1")Integer channel,
@RequestParam(value="registerSource",defaultValue="")String registerSource
){
//默认昵称
String nickname=SystemConfig.USER_NIKENAME_DEFAULT+(int)((Math.random()*9+1)*100000);
return appPermissionService.register(username, password, SystemConfig.USER_HEADER_URL_DEFAULT,nickname,
mobilecode, null, null,0,code,channel);
mobilecode, null, null,0,code,channel,registerSource);
}
......@@ -123,7 +124,8 @@ public class AppUserRest {
@RequestParam(value="type",defaultValue="0")Integer type,
@RequestParam(value="isQQ",defaultValue="0")Integer isQQ,
@RequestParam(value="code",defaultValue="")String code,
@RequestParam(value="channel",defaultValue="1")Integer channel
@RequestParam(value="channel",defaultValue="1")Integer channel,
@RequestParam(value="registerSource",defaultValue="")String registerSource
){
if(StringUtils.isBlank(headimgurl)){
headimgurl=SystemConfig.USER_HEADER_URL_DEFAULT;
......@@ -131,7 +133,7 @@ public class AppUserRest {
if(StringUtils.isBlank(nickname)){
nickname=SystemConfig.USER_NIKENAME_DEFAULT+(int)((Math.random()*9+1)*100000);
}
return appPermissionService.weCahtRegister(username,password,openid, unionid,nickname,headimgurl,type,mobilecode,isQQ,code,channel);
return appPermissionService.weCahtRegister(username,password,openid, unionid,nickname,headimgurl,type,mobilecode,isQQ,code,channel,registerSource);
}
/**
* 手机号码检测是否已绑定
......
......@@ -251,7 +251,7 @@ public class AppPermissionService {
*/
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public JSONObject register(String username, String password, String headimgurl,
String nickname, String mobilecode, String openId, String unionid, Integer type,String code,Integer channel) {
String nickname, String mobilecode, String openId, String unionid, Integer type,String code,Integer channel,String registerSource) {
log.info("register------code====="+code+"----开始进入方法---time===="+System.currentTimeMillis()/1000L);
String activityCode = null;
// 判断参数和验证码
......@@ -348,6 +348,7 @@ public class AppPermissionService {
log.info("register------username====="+username+"----channel===="+channel);
channel=-1;
rsUserDetail.setChannel(channel);
rsUserDetail.setRegisterSource(registerSource);
appUserDetailBiz.insertSelective(rsUserDetail);
log.info("注册:新增用户详情: " + userid+"---time===="+System.currentTimeMillis()/1000L);
/* //绑定上下线关系
......@@ -571,7 +572,7 @@ public class AppPermissionService {
*/
@Transactional
public JSONObject weCahtRegister(String username, String password, String openId,
String unionid, String nickname, String headimgurl, int type, String mobilecode, Integer isQQ,String code,Integer channel) {
String unionid, String nickname, String headimgurl, int type, String mobilecode, Integer isQQ,String code,Integer channel,String registerSource) {
// 校验参数和验证码
if (StringUtils.isBlank(username) || StringUtils.isBlank(mobilecode)) {
return JsonResultUtil.createFailedResult(ResultCode.NULL_CODE, "参数为空");
......@@ -631,6 +632,7 @@ public class AppPermissionService {
userDetail.setIsdel(0);
userDetail.setCrtHost(getIp());
userDetail.setChannel(channel);
userDetail.setRegisterSource(registerSource);
//setCreateIPInfo(userDetail);
appUserDetailBiz.insertSelective(userDetail);
......@@ -664,7 +666,7 @@ public class AppPermissionService {
}
} else if (type == 2) { // 新增
JSONObject register = register(username, password, headimgurl, nickname, mobilecode,
openId, unionid, isQQ,code,channel);
openId, unionid, isQQ,code,channel,registerSource);
if (register.getInteger("status") != ResultCode.SUCCESS_CODE) {
if (register.getInteger("status") == ResultCode.EXIST_CODE) {
return JsonResultUtil.createFailedResult(ResultCode.EXIST_CODE, "用户已存在");
......
......@@ -24,6 +24,8 @@
<result column="person_sign" property="personSign"/>
<result column="remark" property="remark"/>
<result column="channel" property="channel"/>
<result column="register_source" property="registerSource"/>
<result column="mark_name" property="markName"/>
<result column="province_code" property="provinceCode"/>
<result column="city_code" property="cityCode"/>
<result column="crt_host" property="crtHost"/>
......@@ -37,7 +39,6 @@
<result column="memberName" property="memberName"/>
</resultMap>
<!-- 获取用户信息 -->
<select id="getUserInfo" resultMap="AppUserVoMap">
select l.im_userid,l.username,l.wx_openid,l.unionid,l.openid,l.status,l.id_number,l.certification_status,d.* from app_user_login l
......@@ -87,7 +88,9 @@
l.createtime,
l.last_time AS lastTime,
l. STATUS,
z.mark_name AS markName,
d.channel,
d.register_source,
d.is_member,
d.realname,
d.nickname,
......@@ -113,6 +116,7 @@
LEFT JOIN app_user_detail d ON d.userid = l.id
LEFT JOIN app_user_login ul ON ul.id = d.inviter_account
LEFT JOIN base_user_member m ON d.userid = m.user_id
LEFT JOIN xxfc_app.app_version_mark z ON z.mark = d.register_source
LEFT JOIN
(
SELECT
......@@ -154,8 +158,10 @@
l.id AS userid,
l.username,
d.channel,
d.register_source,
d.source,
d.realname,
z.mark_name AS markName,
ml. NAME AS memberName,
aup. NAME AS positionName,
m.crt_time AS timeOfMembership,
......@@ -187,7 +193,8 @@
is_del = 0
) r ON l.id = r.user_id
LEFT JOIN app_user_login pl ON r.parent_id = pl.id
LEFT JOIN app_user_detail pd ON pl.id = pd.userid
LEFT JOIN app_user_detail pd ON pl.id = pd.userid
LEFT JOIN xxfc_app.app_version_mark z ON z.mark = d.register_source
WHERE
l.isdel = 0
and
......@@ -198,6 +205,9 @@
<if test="channel !=null ">
and d.channel=#{channel}
</if>
<if test="registerSource !=null ">
and binary d.register_source=#{registerSource}
</if>
<if test="memberLevel !=null and memberLevel != -1">
and m.member_level = #{memberLevel}
</if>
......@@ -267,23 +277,27 @@ from `app_user_detail` as `aud` left join `app_user_login` as `aul` on aul.id=
<select id="findAllStaffsByCompanyIdAndPostionId"
resultType="com.github.wxiaoqi.security.admin.bo.UserStaffBo">
select * from (select aud.userid as `userId`,aud.realname as `realName`,aud.nickname as `nickName`,aul.username as `phone`,aud.position_id
as `postionId`,aup.name as `postionName`,aupt.company_id as `companyId`,aupt.company_name as `companyName` from `app_user_detail` as `aud`
select * from (select aud.userid as `userId`,aud.realname as `realName`,aud.nickname as `nickName`,aul.username
as `phone`,aud.position_id
as `postionId`,aup.name as `postionName`,aupt.company_id as `companyId`,aupt.company_name as `companyName` from
`app_user_detail` as `aud`
left join `app_user_login` as `aul` on aul.id=aud.userid
left join (select * from `app_user_position_temp` where is_del=0) as `aupt` on aupt.user_id=aul.id
left join `app_user_position` as `aup` on aup.id=aud.position_id where <![CDATA[aud.position_id<>6]]> and aud.isdel=0
<if test="userPostionId!=null">
and aud.`position_id`=#{userPostionId}
</if>
left join (select * from `app_user_position_temp` where is_del=0) as `aupt` on aupt.user_id=aul.id
left join `app_user_position` as `aup` on aup.id=aud.position_id where <![CDATA[aud.position_id<>6]]> and
aud.isdel=0
<if test="userPostionId!=null">
and aud.`position_id`=#{userPostionId}
</if>
<if test="companyId!=null">
and aupt.`company_id`=#{companyId}
and aupt.`company_id`=#{companyId}
</if>
<if test="userIds!=null and userIds.size>0">
and aud.userid in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
</if>) as `saff`
</if>
) as `saff`
left join (
select auswp.user_id, IFNULL(auswp.upIncome, 0) - IFNULL(auswd.dowIncome, 0) as `sellAmount`
from (select `user_id`, sum(commission / (extract/100.0)) as `upIncome`
......@@ -291,7 +305,7 @@ from `app_user_detail` as `aud` left join `app_user_login` as `aul` on aul.id=
where <![CDATA[position_id<>6]]>
and status = 0
<if test="startDate!=null and endDate!=null">
and `crt_time` between #{startTime} and #{endTime}
and `crt_time` between #{startTime} and #{endTime}
</if>
<if test="startDate!=null and endDate==null">
and <![CDATA[
......
package com.xxfc.platform.app.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* Demo class
*
* @author zuoyh
* @date 2020/1/10
*/
@Data
@Table(name = "app_version_mark")
public class AppVersionMark implements Serializable {
private static final long serialVersionUID = 1L;
/**
* app版本标识信息表ID
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("app版本信息表")
private Integer id;
/**
* 标识
*/
@Column(name = "mark")
@ApiModelProperty(value = "标识")
private String mark;
/**
* 标识名称
*/
@Column(name = "mark_name")
@ApiModelProperty(value = "标识名称")
private String markName;
/**
* 标识描述
*/
@Column(name = "mark_remark")
@ApiModelProperty(value = "标识描述")
private String markRemark;
/**
* 是否删除;0-正常;1-删除
*/
@Column(name = "is_del")
@ApiModelProperty(value = "是否删除;0-正常;1-删除")
private Integer isDel;
/**
* 版本标识上传时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "版本上传时间", hidden = true)
private Date crtTime;
/**
* 版本标识更新时间
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "版本标识更新时间", hidden = true)
private Long updTime;
/**
* 版本标识来源类型
*/
@Column(name = "source_type")
@ApiModelProperty(value = "版本标识更新时间", hidden = true)
private String sourceType;
}
package com.xxfc.platform.app.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.sql.Timestamp;
@Data
public class AppVersionMarkDTO {
@ApiModelProperty("app版本信息表")
private Integer id;
@ApiModelProperty(value = "标识")
private String mark;
@ApiModelProperty(value = "标识名称")
private String markName;
@ApiModelProperty(value = "标识描述")
private String markRemark;
@ApiModelProperty(value = "是否删除;0-正常;1-删除")
private Integer isDel;
@ApiModelProperty(value = "版本上传时间", hidden = true)
private Date crtTime;
@ApiModelProperty(value = "版本修改时间", hidden = true)
private Long updTime;
@ApiModelProperty(value = "操作标识 1:新增 2:修改 3:删除")
private int changeMark;
@ApiModelProperty(value = "版本标识更新时间")
private String sourceType;
}
package com.xxfc.platform.app.vo;
import lombok.Data;
@Data
public class AppVersionMarkQuery {
private Integer page;
private Integer limit;
/**
* 标识名称
*/
private String markName;
/**
* 标识
*/
private String mark;
/**
* 标识内容
*/
private String markRemark;
}
package com.xxfc.platform.app.biz;
import com.ace.cache.annotation.CacheClear;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.app.entity.AppVersionMark;
import com.xxfc.platform.app.entity.dto.AppVersionMarkDTO;
import com.xxfc.platform.app.mapper.AppVersionMarkMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
/**
* @Author: zyh
* @Date: 2020/1/10
*/
public class AppVersionMarkBiz extends BaseBiz<AppVersionMarkMapper, AppVersionMark> {
private static final int RANDOM_TWO_LENGTH = 2;
private static final int CHANGE_UPD_APP_MARK = 1;
private static final int APP_MARK_IS_DEL = 1;
private static final int CHANGE_DELETE_APP_MARK = 2;
private static final int NO_RANDOM_REAPPEAR = 50;
public static final int IS_DEL_IOS_OR_ANDROID = 1;
public static final int SUCCESSFUL_OPERATION_CODE = 1;
public static final int FAIL_OPERATION_CODE = 2;
public static final String SUCCESSFUL_OPERATION = "操作成功";
public static final String FAIL_OPERATION = "安卓/苹果不可删除";
/**
* @Description: 新增APP版本标识
* @Param: AppVersionMarkDTO appVersionMarkDTO
* @return:
* @Author: zyh
* @Date: 2020/1/10
*/
@CacheClear
public Map<Integer, String> addAppVersionMark(AppVersionMarkDTO appVersionMarkDTO) {
Map<Integer, String> statusMap = new HashedMap<>();
if (StringUtils.isBlank(appVersionMarkDTO.getMarkName()) || StringUtils.isBlank(appVersionMarkDTO.getMarkRemark())
|| StringUtils.isBlank(appVersionMarkDTO.getSourceType()) || StringUtils.isBlank(appVersionMarkDTO.getMark())) {
statusMap.put(FAIL_OPERATION_CODE, "参数不能为空");
return statusMap;
}
AppVersionMark appVersionMark = new AppVersionMark();
String markNoBlank = appVersionMarkDTO.getMark().replaceAll(" ", "");
int count = mapper.queryIsMark(markNoBlank);
if (count > 0) {
statusMap.put(FAIL_OPERATION_CODE, "标识已存在,请重新输入");
return statusMap;
}
try {
Date date = new Date();
//设置日期格式
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String nowTime = simpleDateFormat.format(date);
Date crtTime = simpleDateFormat.parse(nowTime);
appVersionMark.setCrtTime(crtTime);
} catch (ParseException e) {
e.printStackTrace();
}
appVersionMark.setMark(markNoBlank);
appVersionMark.setSourceType(appVersionMarkDTO.getSourceType());
appVersionMark.setMarkName(appVersionMarkDTO.getMarkName());
appVersionMark.setMarkRemark(appVersionMarkDTO.getMarkRemark());
appVersionMark.setIsDel(0);
// insertSelective(appVersionMark);
mapper.insert(appVersionMark);
statusMap.put(SUCCESSFUL_OPERATION_CODE, SUCCESSFUL_OPERATION);
return statusMap;
}
/**
* @Description: 随机产生,判断数据库是否已经存在
* @return: 标识
* @Author: zyh
* @Date: 2020/1/10
*/
public String getMark() {
String mark = "";
for (int i = 0; i < NO_RANDOM_REAPPEAR; i++) {
mark = getCharAndNumr(RANDOM_TWO_LENGTH);
int count = mapper.queryIsMark(mark);
if (count == 0) {
break;
}
}
return mark;
}
/**
* 生成随机数字和字母组合
*
* @param length
* @return
*/
public static String getCharAndNumr(int length) {
StringBuffer valSb = new StringBuffer();
for (int i = 0; i < length; i++) {
// 输出字母还是数字
String charOrNum = Math.round(Math.random()) % 2 == 0 ? "char" : "num";
if ("char".equalsIgnoreCase(charOrNum)) {
// 字符串 取得大写字母还是小写字母
int choice = Math.round(Math.random()) % 2 == 0 ? 65 : 97;
valSb.append((char) (choice + Math.round(Math.random() * 25)));
} else if ("num".equalsIgnoreCase(charOrNum)) {
// 数字
valSb.append(String.valueOf(Math.round(Math.random() * 9)));
}
}
return valSb.toString();
}
/**
* @Description: app版本标识 更新以及删除
* @Param: No such property: code for class: Script1
* @return:
* @Author: zyh
* @Date: 2020/1/10
*/
@CacheClear
public Map<Integer, String> updAppVersionMark(AppVersionMarkDTO appVersionMarkDTO) {
Map<Integer, String> statusMap = new HashedMap<>();
AppVersionMark appVersionMark = new AppVersionMark();
BeanUtils.copyProperties(appVersionMarkDTO, appVersionMark);
if (appVersionMarkDTO.getChangeMark() == CHANGE_UPD_APP_MARK) {
if (StringUtils.isNotEmpty(appVersionMarkDTO.getMark())) {
String markNoBlank = appVersionMarkDTO.getMark().replaceAll(" ", "");
int count = mapper.queryIsMark(markNoBlank);
if (count >0) {
statusMap.put(FAIL_OPERATION_CODE, "标识已存在,请重新更改标识");
return statusMap;
}
appVersionMark.setMark(markNoBlank);
}
updateSelectiveById(appVersionMark);
} else if (appVersionMarkDTO.getChangeMark() == CHANGE_DELETE_APP_MARK) {
Integer count = mapper.findIosOrAndroidVersionAppMark(appVersionMarkDTO.getId());
if (count.equals(IS_DEL_IOS_OR_ANDROID)) {
statusMap.put(FAIL_OPERATION_CODE, FAIL_OPERATION);
return statusMap;
}
appVersionMark.setIsDel(APP_MARK_IS_DEL);
updateSelectiveById(appVersionMark);
}
statusMap.put(SUCCESSFUL_OPERATION_CODE, SUCCESSFUL_OPERATION);
return statusMap;
}
/**
* @Description: 查询页面展示
* @Param:
* @return: AppVersionMarkDTO appVersionMarkDTO
* @Author: zyh
* @Date: 2020/1/10
*/
public List<AppVersionMarkDTO> findVersionAppMark(String mark) {
List list = mapper.findVersionAppMark(mark);
return list;
}
/**
* @Description: 会员页面查询注册来源 下拉框接口
* @Param:
* @return: list(mark名称)
* @Author: zyh
* @Date: 2020/1/13
*/
public List<AppVersionMarkDTO> findListVersionAppMark() {
List list = mapper.findListVersionAppMark();
return list;
}
}
package com.xxfc.platform.app.mapper;
import com.xxfc.platform.app.entity.AppVersionMark;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.sql.Timestamp;
import java.util.List;
/**
* AppVersionMark Mapper
*
* @author zyh
* @date 2020/1/10
*/
public interface AppVersionMarkMapper extends Mapper<AppVersionMark> {
int queryIsMark(@Param("mark") String mark);
int queryIsMarkNew(@Param("mark") String mark);
void updAppVersionMark(@Param("markName") String markName,
@Param("markRemark") String markRemark,
@Param("isDel") Integer isDel,
@Param("id") Integer id,
@Param("updTime") Timestamp updTime);
List<AppVersionMark> findVersionAppMark(@Param("mark") String mark);
int findIosOrAndroidVersionAppMark(@Param("id") Integer id);
List<AppVersionMark> findListVersionAppMark();
List<AppVersionMark > queryListForUserMember();
}
package com.xxfc.platform.app.rest;
import com.ace.cache.annotation.CacheClear;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.app.biz.AppVersionMarkBiz;
import com.xxfc.platform.app.entity.AppVersionMark;
import com.xxfc.platform.app.entity.dto.AppVersionMarkDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import static com.xxfc.platform.app.biz.AppVersionMarkBiz.FAIL_OPERATION_CODE;
import static com.xxfc.platform.app.biz.AppVersionMarkBiz.SUCCESSFUL_OPERATION_CODE;
/**
* @program: ace-security
* @author: zyh
* @create: 2020-01-10 11:24
**/
@IgnoreUserToken
@RestController
@Slf4j
@RequestMapping("version/mark")
public class AppVersionMarkController extends BaseController<AppVersionMarkBiz, AppVersionMark> {
@Autowired
private AppVersionMarkBiz appVersionMarkBiz;
/**
* @Description: 新增APP版本标识
* @Param: AppVersionMarkDTO appVersionMarkDTO
* @return:
* @Author: zyh
* @Date: 2020/1/10
*/
@PostMapping("/appMarkVersionAdd")
@CacheClear
public ObjectRestResponse addAppVersionMark(@RequestBody AppVersionMarkDTO appVersionMarkDTO) {
try {
Integer status = SUCCESSFUL_OPERATION_CODE;
String message = "";
Map<Integer, String> mapStatus = appVersionMarkBiz.addAppVersionMark(appVersionMarkDTO);
Iterator<Integer> iter = mapStatus.keySet().iterator();
while (iter.hasNext()) {
status = iter.next();
message = mapStatus.get(status);
}
if (status.equals(FAIL_OPERATION_CODE)) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, message);
}
return ObjectRestResponse.succ();
} catch (Exception e) {
log.error("新增失败[{}]", e);
throw new BaseException("新增失败");
}
}
/**
* @Description: app版本标识 更新以及删除
* @Author: zyh
* @Date: 2020/1/10
*/
@PostMapping("updAppMark")
@CacheClear
public ObjectRestResponse updAppVersionMark(@RequestBody AppVersionMarkDTO appVersionMarkDTO) {
try {
Map<Integer, String> map = appVersionMarkBiz.updAppVersionMark(appVersionMarkDTO);
Iterator<Integer> iter = map.keySet().iterator();
Integer status = 1;
String message = "";
while (iter.hasNext()) {
status = iter.next();
message = map.get(status);
}
if (status.equals(1)) {
return ObjectRestResponse.succ();
} else {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, message);
}
} catch (Exception e) {
log.error("更新失败[{}]", e);
throw new BaseException("更新失败");
}
}
/**
* @Description: 页面展示
* @Param: AppVersionMarkQuery query 业务需求:暂时没有查询框
* @return: listJson
* @Author: zyh
* @Date: 2020/1/10
*/
@GetMapping("/findAllByQuery")
public ObjectRestResponse findAllByQuery(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit,
@RequestParam(value = "mark", defaultValue = "") String mark) {
Example example = new Example(AppVersionMark.class);
if (StringUtils.isNotBlank(mark)) {
example.createCriteria().andLike("mark", "%" + mark + "%");
}
example.createCriteria().andEqualTo("isDel", 0);
example.setOrderByClause("`crt_time` desc");
PageHelper.startPage(page, limit);
List<AppVersionMark> listPage = appVersionMarkBiz.selectByExample(example);
return ObjectRestResponse.succ(PageInfo.of(listPage));
}
/**
* @Description: 單獨查詢,根据标识
* @Param: MARK標識
* @return: list
* @Author: zyh
* @Date: 2020/1/10
*/
@GetMapping("/findVersionAppMark")
public ObjectRestResponse findAllByQuery(@RequestParam("mark") String mark) {
return ObjectRestResponse.succ(appVersionMarkBiz.findVersionAppMark(mark));
}
/**
* @Description: 会员页面查询注册来源 下拉框接口
* @Param:
* @return: list(mark名称)
* @Author: zyh
* @Date: 2020/1/13
*/
@GetMapping("/find/listMark")
public ObjectRestResponse findListVersionAppMark() {
return ObjectRestResponse.succ(appVersionMarkBiz.findListVersionAppMark());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxfc.platform.app.mapper.AppVersionMarkMapper">
<select id="queryIsMark" parameterType="java.lang.String" resultType="java.lang.Integer">
SELECT
count(*)
FROM
`app_version_mark`
where
is_del=0
<if test="mark!=null and mark!=''">
and binary mark like concat('%',#{mark},'%')
</if>
</select>
<select id="queryIsMarkNew" parameterType="java.lang.String" resultType="java.lang.Integer">
SELECT
count(*)
FROM
`app_version_mark`
where
is_del=0
<if test="mark!=null and mark!=''">
and binary mark=#{mark}
</if>
</select>
<select id="findVersionAppMark" resultType="com.xxfc.platform.app.entity.AppVersionMark">
select * from
`app_version_mark` a
where
is_del = 0
<if test="mark!=null and mark!=''">
and binary mark like concat('%',#{mark},'%')
</if>
</select>
<select id="findIosOrAndroidVersionAppMark" resultType="java.lang.Integer">
select count(*) from
`app_version_mark` a
where
is_del = 0
<if test="id!=null and id!=''">
and id= #{id}
</if>
and ( mark_name like concat('%','ios','%')
or mark_name like concat('%','安卓','%'))
</select>
<select id="findListVersionAppMark" resultType="com.xxfc.platform.app.entity.AppVersionMark">
select `mark_name`,`mark`
from
`app_version_mark` a
where
is_del = 0
</select>
<select id="queryListForUserMember" resultType="com.xxfc.platform.app.entity.AppVersionMark">
select `mark_name` as registerSource
from
`app_version_mark` a
where
is_del = 0
</select>
</mapper>
\ No newline at end of file
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