Authored by mlge

种草--马甲用户管理

... ... @@ -5,6 +5,7 @@ import com.yohobuy.platform.model.common.ApiResponse;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GrassUserManageReq;
import com.yohobuy.platform.model.grass.response.GrassUserRespBo;
import com.yohobuy.platform.model.grass.response.GrassVirtualUserRespBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
... ... @@ -41,5 +42,30 @@ public class GrassUserManageController {
return new ApiResponse.ApiResponseBuilder().build();
}
/**
* 马甲用户列表
* @param req
* @return
*/
@RequestMapping("/grassVirtualList")
@ResponseBody
public ApiResponse grassVirtualList(@RequestBody GrassUserManageReq req){
PageResponseVO<GrassVirtualUserRespBo> result = userService.grassVirtualList(req);
return new ApiResponse.ApiResponseBuilder().data(result).build();
}
/**
* 修改马甲用户信息
* @param req
* @return
*/
@RequestMapping("/updateVirtualUser")
@ResponseBody
public ApiResponse updateVirtualUser(@RequestBody GrassUserManageReq req){
userService.updateVirtualUser(req);
return new ApiResponse.ApiResponseBuilder().build();
}
}
... ...
... ... @@ -32,4 +32,6 @@ public interface IGrassArticleService {
ArticleDetailRspBo getArticleById(GrassArticleReq req) throws PlatformException;
List<Integer> getUidByNickName(String nickName);
}
... ...
... ... @@ -4,6 +4,7 @@ import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GrassTopicReq;
import com.yohobuy.platform.model.grass.request.GrassUserManageReq;
import com.yohobuy.platform.model.grass.response.GrassUserRespBo;
import com.yohobuy.platform.model.grass.response.GrassVirtualUserRespBo;
import com.yohobuy.platform.model.grass.response.TopicRespBo;
import java.util.List;
... ... @@ -17,4 +18,8 @@ public interface IGrassUserService {
void changeGrassUserStatus(GrassUserManageReq req);
PageResponseVO<GrassVirtualUserRespBo> grassVirtualList(GrassUserManageReq req);
void updateVirtualUser(GrassUserManageReq req);
}
... ...
... ... @@ -332,7 +332,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
return rsp;
}
private List<Integer> getUidByNickName(String nickName){
public List<Integer> getUidByNickName(String nickName){
String url = uicUrl + "/UserInfoRest/getUserInfoByNickName";
BaseReqBO<String> uicReq = new BaseReqBO<>();
uicReq.setParam(nickName);
... ...
package com.yohobuy.platform.grass.service.impl;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.quartz.utils.DateUtils;
import com.yoho.service.model.request.UserBaseReqBO;
import com.yoho.service.model.response.CommonRspBO;
import com.yoho.service.model.social.request.BaseReqBO;
import com.yoho.service.model.social.request.UicUserReqBO;
import com.yoho.service.model.social.response.UserInfoRspBO;
... ... @@ -8,12 +11,16 @@ import com.yoho.service.model.social.response.UserLoginInfoRspBO;
import com.yohobuy.platform.common.util.DateUtil;
import com.yohobuy.platform.dal.grass.IGrassArticleDao;
import com.yohobuy.platform.dal.grass.IGrassUserAchieveDAO;
import com.yohobuy.platform.dal.grass.IGrassVirtualUserDao;
import com.yohobuy.platform.dal.grass.model.GrassArticle;
import com.yohobuy.platform.dal.grass.model.GrassUserAchieve;
import com.yohobuy.platform.dal.grass.model.GrassVirtualUser;
import com.yohobuy.platform.grass.service.IGrassArticleService;
import com.yohobuy.platform.grass.service.IGrassUserService;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GrassUserManageReq;
import com.yohobuy.platform.model.grass.response.GrassUserRespBo;
import com.yohobuy.platform.model.grass.response.GrassVirtualUserRespBo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringEscapeUtils;
... ... @@ -45,6 +52,12 @@ public class GrassUserServiceImpl implements IGrassUserService{
private IGrassArticleDao articleDao;
@Autowired
private IGrassVirtualUserDao virtualUserDao;
@Autowired
IGrassArticleService grassArticleService;
@Autowired
private ServiceCaller serviceCaller;
@Value("${uic.service.url:http://uic.yohoops.org/uic}")
... ... @@ -104,6 +117,123 @@ public class GrassUserServiceImpl implements IGrassUserService{
}
/**
* 马甲用户列表
* @param req
* @return
*/
@Override
public PageResponseVO<GrassVirtualUserRespBo> grassVirtualList(GrassUserManageReq req) {
logger.info("enter grassVirtualList req={}", req);
PageResponseVO responseVO = new PageResponseVO();
responseVO.setList(new ArrayList());
responseVO.setTotal(0);
responseVO.setPage(req.getPage());
responseVO.setSize(req.getSize());
List<Integer> uids = new ArrayList<>();
if(StringUtils.isNotEmpty(req.getNickName())){//昵称,先去uic查
uids = grassArticleService.getUidByNickName(req.getNickName());
if(CollectionUtils.isEmpty(uids)){
logger.info("grassVirtualList result is null, nickName not found, req={}", req);
return responseVO;
}
}
if(req.getUid() != null){
uids.add(req.getUid());
}
Map<String,Object> params = new HashMap<>();
params.put("status",req.getStatus() == null || req.getStatus() == 8 ? null : req.getStatus());
params.put("nickName",req.getNickName());
params.put("uids",uids);
params.put("startTime",req.getStartTime());
params.put("endTime",req.getEndTime());
int total = virtualUserDao.countByCondition(params);
responseVO.setTotal(total);
if(total == 0){
logger.info("grassVirtualList total is 0, req={}", req);
return responseVO;
}
List<GrassVirtualUser> list = virtualUserDao.selectByPage(params, req.getStart(), req.getSize());
List<GrassVirtualUserRespBo> data = buildVirtualInfo(list);
responseVO.setList(data);
logger.info("grassVirtualList success! req={}, total = {}",req, total);
return responseVO;
}
/**
* 修改马甲用户信息
* @param req
*/
@Override
public void updateVirtualUser(GrassUserManageReq req) {
logger.info("enter updateVirtualUser req={}", req);
Integer type = req.getType() == null ? 0 : req.getType() ;
if(type == 1){//修改状态
virtualUserDao.changeStatusByUid(req.getUid(), req.getStatus());
return;
}
//修改基本信息(头像,签名等)
String url = uicUrl + "/UserInfoRest/updateUserBase";
UserBaseReqBO uicReq = new UserBaseReqBO();
uicReq.setUid(req.getUid());
uicReq.setNick_name(req.getNickName());
uicReq.setHeadIco(req.getHeadIcon());
logger.info("updateVirtualUser call uic.modifyUserBase url ={}, uicReq={}", url, uicReq);
//调uic 的接口(修改头像等)
serviceCaller.post("uic.modifyUserBase", url, uicReq, CommonRspBO.class, null).get();
//
GrassUserAchieve grassUserAchieve = userAchieveDAO.selectByUid(req.getUid());
if(grassUserAchieve == null){
grassUserAchieve = new GrassUserAchieve();
grassUserAchieve.setUid(req.getUid());
grassUserAchieve.setSignature(req.getSignature());
grassUserAchieve.setCreateTime((int) (System.currentTimeMillis() /1000));
userAchieveDAO.insertSelective(grassUserAchieve);
logger.info("updateVirtualUser create userAchieve success! req={} ", req);
}else{
grassUserAchieve.setSignature(Optional.ofNullable(req.getSignature()).orElse(""));
grassUserAchieve.setUpdateTime((int) (System.currentTimeMillis() /1000));
userAchieveDAO.updateSelective(grassUserAchieve);
logger.info("updateVirtualUser update userAchieve success! req={} ", req);
}
}
//马甲用户的详细信息
private List<GrassVirtualUserRespBo> buildVirtualInfo(List<GrassVirtualUser> list) {
List<GrassVirtualUserRespBo> result = new ArrayList<>();
if(CollectionUtils.isEmpty(list)){
return result;
}
//查询用户的头像等基本信息
//用户的基本信息(昵称 头像等)
List<Integer> uids = list.stream().map(GrassVirtualUser::getUid).collect(Collectors.toList());
Map<Integer,UserInfoRspBO> userInfoMap = getUsersInfo(uids);
//获取签名信息
List<GrassUserAchieve> userAchieves = userAchieveDAO.selectByUids(uids);
Map<Integer,String > userAchieveMap = userAchieves.stream().collect(Collectors.toMap(GrassUserAchieve::getUid, obj -> obj.getSignature() == null ? "" : obj.getSignature()));
//组装信息
for(GrassVirtualUser user : list){
GrassVirtualUserRespBo bo = new GrassVirtualUserRespBo();
bo.setUid(user.getUid());
UserInfoRspBO userInfoRspBO = userInfoMap.get(user.getUid());
bo.setNickName(userInfoRspBO == null ? "" : userInfoRspBO.getNickName());
bo.setHeadIcon(userInfoRspBO == null ? "" : buildHeadIcon(userInfoRspBO.getHeadIco()));
bo.setSignature(userAchieveMap.get(user.getUid()) == null ? "" : userAchieveMap.get(user.getUid()));
bo.setCreateTimeStr(DateUtil.getDateFormatFromInt(user.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
bo.setStatus(user.getStatus());
result.add(bo);
}
return result;
}
/**
* 根据昵称查询
* 先去查询uic --精确查询
* @param req
... ...
<!DOCTYPE html>
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
<form name="topicForm" id="topicForm" method="post">
<div style="margin-top: 20px;margin-left: 30px">
<table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>UID</label> <br>
<input id="uid" name="uid" class="easyui-textbox" style="width: 380px;" readonly='readonly'/>
</td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>马甲昵称</label> <br>
<input id="nickName" name="nickName" class="easyui-textbox" style="width: 380px;"/>
</td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>头像</label> <br>
<div id="imageUpload">
</div>
<!-- <span style=" margin-left: 10px; color: red"> 图片宽高(186x170)</span>-->
</td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>马甲简介</label> <br>
<textarea id="signature" name="signature" style="width: 380px;" rows="6" placeholder=""
required="true" maxlength="500"></textarea>
</td>
</tr>
</table>
</div>
</form>
</div>
<script>
$(function () {
$("#nickName").textbox({
required: true,
missingMessage: "昵称不能为空",
prompt: "请输入昵称"
});
$("#imageUpload").imageUpload({
width: 171,
height: 120,
realInputName: "headIcon",
url: serverContextPath + '/fileupload/uploadFile',
queryParams: {
bucket: "activity"
},
onBeforeSubmit: function () {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
},
filterFileName: function (data) {
debugger;
if (!data || data.code != 200) {
$.messager.progress("close");
$.messager.alert("错误", data.message);
return "";
}
return data.data.url;
},
onLoadSuccess: function (data) {
$.messager.progress("close");
//$("#imageUpload").hide();
//$("#fileName").val(data.data.fileName);
//$("#videoSize").val(data.data.fileSize); //如果有大小校验
/*$("#callBackDiv").html("<div id='videoUploadDiv' class='image-upload' style='position: relative;top:19px;width: 120px; height: 150px;'><img id='imageShow' src='"+data.data.url+"?vframe/jpg/offset/0' width='120' height='150'/></div>"
+"<span style='position: relative;top: -40px;left: 30px;'>"+data.data.fileName+"</span><span style='position: relative;left: 50px;top: -40px;'>"+data.data.fileSize+"M</span>").show();
*/
return false;
}
});
//加载数据
var data = paramObject.mkData;
$("#uid").textbox("setValue", data.uid);
$("#nickName").textbox("setValue", data.nickName);
$("#signature").html(data.signature);
//图片
$("#imageUpload").imageUpload('setValue', data.headIcon);
});
</script>
</html>
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/pfcms/js/include.js"></script>
<script src="/pfcms/js/ajaxfileupload.js"></script>
<style>
.btn-long {
width: 120px;
height: 37px;
line-height: 37px;
font-size: 15px;
color: white;
border-radius: 5px;
display: inline-block;
cursor: pointer;
text-align: center;
}
.btn-long:hover {
opacity: 0.9;
}
</style>
</head>
<body class="easyui-layout">
<div region="north" style="height: 200px;">
<script>
document.write(addHead('种草社区管理', '马甲管理'));
</script>
<div style="margin-left: 20px;margin-top: 10px">
<input class="easyui-combobox" id="statusParam">
</input>
<input class="easyui-textbox" id="nickNameParam" style="width: 140px">
</input>
<input class="easyui-textbox" id="uidParam" style="width: 140px">
</input>
<input id="startTimeStr" name="startTimeStr" class="easyui-datetimebox" data-options="prompt:'开始时间'"/>
~ &nbsp;
<input id="endTimeStr" name="endTimeStr" class="easyui-datetimebox" data-options="prompt:'结束时间'"/>
</input>
<a id="searchBtn" class="btn-info">查询</a>
<!--<a id="addActivityBtn" class="btn-success">新增</a>-->
<a id="allBtn" class="btn-info">全部</a>
</div>
</div>
<div region="center" id="labelList" style="margin-left: 20px">
<table id="labelListTable"></table>
</div>
</body>
<script>
$(function () {
//用于页面刷新后的数据行定位
var index = "";
$("#allBtn").linkbutton({
iconCls: "icon-search",
onClick: function () {
$("#labelListTable").datagrid("load", {});
}
});
$("#nickNameParam").textbox({
required: false,
prompt: "昵称"
});
$("#uidParam").textbox({
required: false,
prompt: "UID"
});
$("#statusParam").combobox({
valueField: "value",
textField: "text",
required: false,
prompt: "请选择状态",
data: [{text: "请选择状态", value: ""}, {text: "全部", value: "8"},{text: "正常", value: "1"}, {text: "停用", value: "0"}]
});
$("#searchBtn").linkbutton({
iconCls: "icon-search",
onClick: function () {
var startTime = "";
var endTime = "";
if ($("#startTimeStr").datetimebox('getValue') != '') {
startTime = parseInt(new Date($("#startTimeStr").datetimebox('getValue')).getTime() / 1000);
}
if ($("#endTimeStr").datetimebox('getValue') != '') {
endTime = parseInt(new Date($("#endTimeStr").datetimebox('getValue')).getTime() / 1000);
}
$("#labelListTable").datagrid("load", {
uid: $("#uidParam").textbox("getValue"),
nickName:$("#nickNameParam").textbox("getValue"),
status: $("#statusParam").combobox("getValue"),
startTime: startTime,
endTime: endTime
});
}
});
// 检索按钮
$("#labelListTable").myDatagrid({
fit: true,
fitColumns: true,
striped: true,
/*queryParams: {
rewardName: $("#rewardName1").textbox("getValue"),
status: $("#rewardstatus1").combobox("getValue"),
type: $("#rewardtype1").combobox("getValue")
},*/
url: serverContextPath + "/grassUserManage/grassVirtualList",
method: 'POST',
loadFilter: function (data) {
var tmp = defaultLoadFilter(data);
tmp.rows = tmp.list;
return tmp;
},
columns: [[
{
title: "马甲UID",
field: "uid",
width: 15,
align: "uid"
},
{
title: "昵称",
field: "nickName",
width: 30,
align: "left"
},
{
title: "头像",
field: "headIcon",
width: 20,
align: "left",
formatter: function (value, rowData, rowIndex) {
if(value == null || value==""){
return "";
}
return '<div><img style="width: 100px;height: 100px" src="'+value+'"/></div>';
}
}, {
title: "马甲简介",
field: "signature",
width: 35,
align: "left"
},
{
title: "创建时间",
field: "createTimeStr",
width: 25,
align: "left"
}, {
title: "状态",
field: "status",
width: 25,
align: "left",
formatter: function (value, rowData, rowIndex) {
if (value == 1) {
return "正常";
} else {
return "停用";
}
}
},
{
title: "操作",
field: "ddg",
width: 40,
align: "center",
formatter: function (value, rowData, rowIndex) {
//停用 启用 修改
var str = "<a role='changeStatus' style='margin-left:10px;background-color: #ffa951' changedStatus='1' dataId='" + rowData.id + "' index='" + rowIndex + "'>启用</a>";
if(rowData.status == 1){
str = "<a role='changeStatus' style='margin-left:10px;background-color: #ffa951' changedStatus='0' dataId='" + rowData.id + "' index='" + rowIndex + "'>停用</a>";
}
str += "<a role='edit' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #31b0d5' index='" + rowIndex + "'>编辑</a>";
return str ;
}
}
]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: true,
onLoadSuccess: function (data) {
if (index != "") {
$(this).datagrid("scrollTo", index);
index = "";
}
// 编辑
$(this).datagrid("getPanel").find("a[role='edit']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
index = $(this).attr("index");
var row = $("#labelListTable").datagrid('getData').rows[index];
getEditDialog(row);
}
});
// 上架下架
$(this).datagrid("getPanel").find("a[role='changeStatus']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
var index = $(this).attr("index");
var row = $("#labelListTable").datagrid('getData').rows[index];
row.status = $(this).attr("changedStatus");
changeStatus(row);
}
});
}
});
// 启用 停用
function changeStatus(data) {
var param = {
uid: data.uid,
status: data.status,
type: 1
};
$.post(serverContextPath + "/grassUserManage/updateVirtualUser", param, function (data) {
if (data.code == 200) {
//刷新table
$("#labelListTable").datagrid("reload");
$.messager.show({
title: "提示",
msg: "更新成功!",
height: 120
});
} else {//
$.messager.alert("失败", "更新失败,请稍后再试!", "error");
}
}, "json");
}
// 编辑分组
function getEditDialog(data) {
var labelList = $("<div id='labelList'>").appendTo($(document.body));
var title = "修改马甲资料";
var textVar = data == null ? "保存" : "保存";
var msgVar = "确定修改吗";
window.self.paramObject.mkData = data;
$(labelList).myDialog({
title: title,
width: "70%",
height: "80%",
resizable: false,
buttons: [{
id: "saveBtn",
text: textVar,
iconCls: "icon-save",
handler: function () {
$("#topicForm").form("submit", {
url: serverContextPath + "/grassUserManage/updateVirtualUser",
onSubmit: function (param) {
if (data != null) {
param.id = data.id;
}
//1)表单基本检查
if (!$("#topicForm").form("validate")) {
return false;
}
//2)是否上传了图片
var imageCount = 0;
$("input[name='headIcon']").each(function (j, item) {
var url = item.value;
if (url != '') {
imageCount++;
}
});
if (imageCount == 0) {
$.messager.alert("保存失败", "至少要选择一张图片", "error");
return false;
}
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后..."
});
return true;
},
success: function (data) {
$.messager.progress("close");
data = JSON.parse(data);
if (data.code == 200) {
$(labelList).dialog("close");
$("#labelListTable").datagrid("reload");
$.messager.show({
title: "提示",
msg: title + "成功!",
height: 120
});
} else {
$.messager.alert("失败", "操作失败", "error");
}
}
});
}
}, {
text: "关闭",
iconCls: "icon-cancel",
handler: function () {
$.messager.confirm("确认", "确认关闭吗?", function (flag) {
if (flag) {
$(labelList).dialog("close");
}
});
}
}],
modal: true,
href: contextPath + "/html/grass/userManage/virtualEdit.html",
});
}
});
</script>
</html>
\ No newline at end of file
... ...