Commit dbd530c1 authored by libin's avatar libin

用户行为保存

parent ea373242
...@@ -68,7 +68,8 @@ public class TokenAop { ...@@ -68,7 +68,8 @@ public class TokenAop {
if (AppUserDTO.class.equals(parameter.getType())){ if (AppUserDTO.class.equals(parameter.getType())){
//token为空 //token为空
if (StringUtils.isEmpty(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(); args[i]= userFeign.userDetailByToken(token).getData();
break; 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 { ...@@ -21,12 +21,14 @@ public class CustomerBehaviorNoteDTO implements Serializable {
@ApiModelProperty(value = "用户id") @ApiModelProperty(value = "用户id")
private String customerId; private String customerId;
/**
* 访问者身份 {@link com.xxfc.platform.user.behavior.common.IdentityEnum}
*/
@ApiModelProperty(value = "1-游客;2-用户") @ApiModelProperty(value = "1-游客;2-用户")
private Integer customerType; private Integer customerType;
/** /**
* 行为类型(见枚举) * 行为类型 {@link com.xxfc.platform.user.behavior.common.BehaviorEnum}
*/ */
@ApiModelProperty(value = "行为类型(见枚举)") @ApiModelProperty(value = "行为类型(见枚举)")
private Integer type; private Integer type;
......
...@@ -38,14 +38,14 @@ public class CustomerBehaviorNotes implements Serializable { ...@@ -38,14 +38,14 @@ public class CustomerBehaviorNotes implements Serializable {
private String customerId; private String customerId;
/** /**
* 1-游客;2-用户 * 访问者身份 {@link com.xxfc.platform.user.behavior.common.IdentityEnum}
*/ */
@Column(name = "customer_type") @Column(name = "customer_type")
@ApiModelProperty(value = "1-游客;2-用户") @ApiModelProperty(value = "1-游客;2-用户")
private Integer customerType; private Integer customerType;
/** /**
* 行为类型(见枚举) * 行为类型 {@link com.xxfc.platform.user.behavior.common.BehaviorEnum}
*/ */
@Column(name = "type") @Column(name = "type")
@ApiModelProperty(value = "行为类型(见枚举)") @ApiModelProperty(value = "行为类型(见枚举)")
...@@ -62,7 +62,7 @@ public class CustomerBehaviorNotes implements Serializable { ...@@ -62,7 +62,7 @@ public class CustomerBehaviorNotes implements Serializable {
* 创建时间 * 创建时间
*/ */
@Column(name = "crt_time") @Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true ) @ApiModelProperty(value = "创建时间", hidden = true)
private Long crtTime; private Long crtTime;
} }
package com.xxfc.platform.user.behavior.biz; 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 org.springframework.stereotype.Service;
import com.xxfc.platform.user.behavior.entity.CustomerBehaviorNotes; import com.xxfc.platform.user.behavior.entity.CustomerBehaviorNotes;
import com.xxfc.platform.user.behavior.mapper.CustomerBehaviorNotesMapper; import com.xxfc.platform.user.behavior.mapper.CustomerBehaviorNotesMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.time.Instant;
/** /**
* 用户行为记录表 * 用户行为记录表
* *
...@@ -15,4 +19,11 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz; ...@@ -15,4 +19,11 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
*/ */
@Service @Service
public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMapper,CustomerBehaviorNotes> { 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; package com.xxfc.platform.user.behavior.config;
import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
...@@ -43,7 +42,6 @@ public class SwaggerConfig { ...@@ -43,7 +42,6 @@ public class SwaggerConfig {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
.select() .select()
.apis(RequestHandlerSelectors.basePackage("com.xxfc.platform.activity.rest")) .apis(RequestHandlerSelectors.basePackage("com.xxfc.platform.activity.rest"))
//.apis(RequestHandlerSelectors.any())
.build() .build()
.globalOperationParameters(pars) .globalOperationParameters(pars)
.apiInfo(apiInfo()); .apiInfo(apiInfo());
......
...@@ -5,7 +5,12 @@ import org.springframework.context.annotation.Bean; ...@@ -5,7 +5,12 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/12 15:27
*/
@Configuration("campsiteWebConfig") @Configuration("campsiteWebConfig")
@Primary @Primary
public class WebConfiguration implements WebMvcConfigurer { public class WebConfiguration implements WebMvcConfigurer {
......
package com.xxfc.platform.user.behavior.rest; 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.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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
/** /**
* @author libin * @author libin
* @version 1.0 * @version 1.0
* @description * @description 用户行为日志*记录
* @data 2019/8/12 14:14 * @data 2019/8/12 14:14
*/ */
@RestController @RestController
@RequestMapping("customerBehaviorNotes") @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