Commit dbd530c1 authored by libin's avatar libin

用户行为保存

parent ea373242
......@@ -68,7 +68,8 @@ public class TokenAop {
if (AppUserDTO.class.equals(parameter.getType())){
//token为空
if (StringUtils.isEmpty(token)){
return ObjectRestResponse.createFailedResult(4004,"token不能为空");
// return ObjectRestResponse.createFailedResult(4004,"token不能为空");
args[i]= new AppUserDTO();
}
args[i]= userFeign.userDetailByToken(token).getData();
break;
......
package com.xxfc.platform.user.behavior.common;
/**
* @author libin
* @version 1.0
* @description 用户行为枚举
* @data 2019/8/12 14:57
*/
public enum BehaviorEnum {
}
package com.xxfc.platform.user.behavior.common;
/**
* @author libin
* @version 1.0
* @description 身份枚举
* @data 2019/8/12 14:53
*/
public enum IdentityEnum {
/**
* 游客
*/
VISITOR(1),
/**
* app用户
*/
USER(2);
private int code;
IdentityEnum(int code){
this.code = code;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
......@@ -21,12 +21,14 @@ public class CustomerBehaviorNoteDTO implements Serializable {
@ApiModelProperty(value = "用户id")
private String customerId;
/**
* 访问者身份 {@link com.xxfc.platform.user.behavior.common.IdentityEnum}
*/
@ApiModelProperty(value = "1-游客;2-用户")
private Integer customerType;
/**
* 行为类型(见枚举)
* 行为类型 {@link com.xxfc.platform.user.behavior.common.BehaviorEnum}
*/
@ApiModelProperty(value = "行为类型(见枚举)")
private Integer type;
......
......@@ -12,7 +12,7 @@ import java.io.Serializable;
/**
* 用户行为记录表
*
*
* @author libin
* @email 18178966185@163.com
* @date 2019-08-12 14:03:55
......@@ -20,49 +20,49 @@ import java.io.Serializable;
@Data
@Table(name = "customer_behavior_notes")
public class CustomerBehaviorNotes implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键id")
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键id")
private Integer id;
/**
* 用户id
/**
* 用户id
*/
@Column(name = "customer_id")
@ApiModelProperty(value = "用户id")
@ApiModelProperty(value = "用户id")
private String customerId;
/**
* 1-游客;2-用户
/**
* 访问者身份 {@link com.xxfc.platform.user.behavior.common.IdentityEnum}
*/
@Column(name = "customer_type")
@ApiModelProperty(value = "1-游客;2-用户")
@ApiModelProperty(value = "1-游客;2-用户")
private Integer customerType;
/**
* 行为类型(见枚举)
/**
* 行为类型 {@link com.xxfc.platform.user.behavior.common.BehaviorEnum}
*/
@Column(name = "type")
@ApiModelProperty(value = "行为类型(见枚举)")
@ApiModelProperty(value = "行为类型(见枚举)")
private Integer type;
/**
* 类型id
/**
* 类型id
*/
@Column(name = "type_id")
@ApiModelProperty(value = "类型id")
@ApiModelProperty(value = "类型id")
private Integer typeId;
/**
* 创建时间
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
@ApiModelProperty(value = "创建时间", hidden = true)
private Long crtTime;
}
package com.xxfc.platform.user.behavior.biz;
import com.xxfc.platform.user.behavior.dto.CustomerBehaviorNoteDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.xxfc.platform.user.behavior.entity.CustomerBehaviorNotes;
import com.xxfc.platform.user.behavior.mapper.CustomerBehaviorNotesMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.time.Instant;
/**
* 用户行为记录表
*
......@@ -15,4 +19,11 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
*/
@Service
public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMapper,CustomerBehaviorNotes> {
public void saveCustomerBehavior(CustomerBehaviorNoteDTO customerBehaviorNoteDTO) {
CustomerBehaviorNotes customerBehaviorNotes = new CustomerBehaviorNotes();
BeanUtils.copyProperties(customerBehaviorNoteDTO,customerBehaviorNotes);
customerBehaviorNotes.setCrtTime(Instant.now().toEpochMilli());
mapper.insertSelective(customerBehaviorNotes);
}
}
\ No newline at end of file
package com.xxfc.platform.user.behavior.config;
import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
......@@ -43,7 +42,6 @@ public class SwaggerConfig {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.xxfc.platform.activity.rest"))
//.apis(RequestHandlerSelectors.any())
.build()
.globalOperationParameters(pars)
.apiInfo(apiInfo());
......
......@@ -5,7 +5,12 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/12 15:27
*/
@Configuration("campsiteWebConfig")
@Primary
public class WebConfiguration implements WebMvcConfigurer {
......
package com.xxfc.platform.user.behavior.rest;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.user.behavior.biz.CustomerBehaviorNotesBiz;
import com.xxfc.platform.user.behavior.entity.CustomerBehaviorNotes;
import com.xxfc.platform.user.behavior.common.IdentityEnum;
import com.xxfc.platform.user.behavior.dto.CustomerBehaviorNoteDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
/**
* @author libin
* @version 1.0
* @description
* @description 用户行为日志*记录
* @data 2019/8/12 14:14
*/
@RestController
@RequestMapping("customerBehaviorNotes")
public class CustomerBehaviorNotesController extends BaseController<CustomerBehaviorNotesBiz,CustomerBehaviorNotes> {
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CustomerBehaviorNotesController {
private final CustomerBehaviorNotesBiz customerBehaviorNotesBiz;
@PostMapping("app/unauth/save")
public ObjectRestResponse<Void> saveCustomerBehavior(@RequestBody CustomerBehaviorNoteDTO customerBehaviorNoteDTO, AppUserDTO appUserDTO) {
if (Objects.nonNull(appUserDTO.getUserid())) {
customerBehaviorNoteDTO.setCustomerId(String.valueOf(appUserDTO.getUserid()));
customerBehaviorNoteDTO.setCustomerType(IdentityEnum.USER.getCode());
}else {
customerBehaviorNoteDTO.setCustomerType(IdentityEnum.VISITOR.getCode());
}
customerBehaviorNotesBiz.saveCustomerBehavior(customerBehaviorNoteDTO);
return ObjectRestResponse.succ();
}
}
\ No newline at end of file
package com.xxfc.platform.user.behavior.rest.admin;
import com.xxfc.platform.user.behavior.biz.CustomerBehaviorNotesBiz;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author libin
* @version 1.0
* @description 用户行为日志*后台统计
* @data 2019/8/12 15:16
*/
@RestController
@RequestMapping("/admin/customerBehaviorNotes")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CustomerBehaviorNotesAdminController {
private final CustomerBehaviorNotesBiz customerBehaviorNotesBiz;
}
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