package com.sinata.modular.mall.controller;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.sinata.core.base.controller.BaseController;
|
import com.sinata.core.common.annotion.BussinessLog;
|
import com.sinata.core.common.annotion.Permission;
|
import com.sinata.core.common.constant.factory.PageFactory;
|
import com.sinata.core.log.LogObjectHolder;
|
import com.sinata.modular.mall.model.MallUserEvaluation;
|
import com.sinata.modular.mall.service.IMallUserEvaluationService;
|
import com.sinata.modular.member.model.MemUser;
|
import com.sinata.modular.member.service.IMemMerchantService;
|
import com.sinata.modular.member.service.IMemUserService;
|
import org.apache.commons.collections.CollectionUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.util.StringUtils;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
|
/**
|
* 用户评价控制器
|
*
|
* @author goku
|
*/
|
@Controller
|
@RequestMapping("/mallUserEvaluation")
|
public class MallUserEvaluationController extends BaseController {
|
|
private String PREFIX = "/mall/mallUserEvaluation/";
|
|
@Autowired
|
private IMallUserEvaluationService mallUserEvaluationService;
|
|
@Autowired
|
private IMemUserService memUserService;
|
|
@Autowired
|
private IMemMerchantService memMerchantService;
|
|
/**
|
* 跳转到用户评价首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "mallUserEvaluation.html";
|
}
|
|
/**
|
* 跳转到添加用户评价
|
*/
|
@RequestMapping("/mallUserEvaluation_add")
|
public String mallUserEvaluationAdd() {
|
return PREFIX + "mallUserEvaluation_add.html";
|
}
|
|
/**
|
* 跳转到修改用户评价
|
*/
|
@RequestMapping("/mallUserEvaluation_update/{mallUserEvaluationId}")
|
public String mallUserEvaluationUpdate(@PathVariable Integer mallUserEvaluationId, Model model) {
|
MallUserEvaluation mallUserEvaluation = mallUserEvaluationService.selectById(mallUserEvaluationId);
|
model.addAttribute("item", mallUserEvaluation);
|
LogObjectHolder.me().set(mallUserEvaluation);
|
return PREFIX + "mallUserEvaluation_edit.html";
|
}
|
|
/**
|
* 获取用户评价列表
|
*
|
* @param showId 用户id
|
* @param state 是否显示,0显示,1隐藏
|
*/
|
@ResponseBody
|
@RequestMapping(value = "/list")
|
public Object list(String beginTime, String endTime, String nikeName, String phone, String showId, Integer state) {
|
Page<Map<String, Object>> page = new PageFactory().defaultPage();
|
Wrapper wrapper = new EntityWrapper<MallUserEvaluation>()
|
.ne("is_delete", 1).orderBy("id", false);
|
|
// 时间搜索
|
if (!StringUtils.isEmpty(beginTime)) {
|
wrapper.ge("create_time", beginTime + " 00:00:00");
|
}
|
if (!StringUtils.isEmpty(endTime)) {
|
wrapper.le("create_time", endTime + " 23:59:59");
|
}
|
if (state != null) {
|
wrapper.eq("state", state);
|
}
|
List<Integer> userIds = null;
|
if (!StringUtils.isEmpty(nikeName) || !StringUtils.isEmpty(phone) || !StringUtils.isEmpty(showId)) {
|
Wrapper<MemUser> memUserWrapper = new EntityWrapper<MemUser>().eq("is_delete", 0);
|
if (!StringUtils.isEmpty(nikeName)) {
|
memUserWrapper.like("nick_name", nikeName);
|
}
|
if (!StringUtils.isEmpty(phone)) {
|
memUserWrapper.like("phone", phone);
|
}
|
if (!StringUtils.isEmpty(showId)) {
|
memUserWrapper.like("show_id", showId);
|
}
|
List<MemUser> memUserList = this.memUserService.selectList(memUserWrapper);
|
if (CollectionUtils.isNotEmpty(memUserList)) {
|
userIds = memUserList.stream().map(o -> o.getId()).collect(Collectors.toList());
|
}
|
}
|
if (CollectionUtils.isNotEmpty(userIds)) {
|
wrapper.in("user_id", userIds);
|
}
|
|
|
// 查询数据列表
|
List<Map<String, Object>> list = mallUserEvaluationService.selectMapsPage(page, wrapper).getRecords();
|
// 封装用户信息
|
memUserService.wrapperMapUser(list, "userId");
|
//商家信息
|
memMerchantService.wrapperMapMerchant(list, "merchantId");
|
page.setRecords(list);
|
return super.packForBT(page);
|
}
|
|
/**
|
* 新增用户评价
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "新增用户评价")
|
@RequestMapping(value = "/add")
|
public Object add(MallUserEvaluation mallUserEvaluation) {
|
mallUserEvaluationService.insert(mallUserEvaluation);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除/批量删除
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "删除/批量删除用户评价")
|
@RequestMapping(value = "/delete")
|
public Object delete(@RequestParam String ids) {
|
// 逻辑删除
|
mallUserEvaluationService.updateForSet("is_delete = 1", new EntityWrapper<MallUserEvaluation>().in("id", ids.split(",")));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改用户评价
|
*/
|
@Permission
|
@ResponseBody
|
@BussinessLog(value = "修改用户评价")
|
@RequestMapping(value = "/update")
|
public Object update(MallUserEvaluation mallUserEvaluation) {
|
mallUserEvaluationService.updateById(mallUserEvaluation);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改用户评价状态
|
*/
|
@ResponseBody
|
@BussinessLog(value = "修改用户评价状态")
|
@RequestMapping(value = "/updateState")
|
public Object updateState(@RequestParam String ids, Integer state) {
|
mallUserEvaluationService.updateForSet("state = " + state, new EntityWrapper<MallUserEvaluation>().in("id", ids));
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 跳转用户评价详情
|
*/
|
@RequestMapping(value = "/detail/{mallUserEvaluationId}")
|
public Object detail(@PathVariable("mallUserEvaluationId") Integer mallUserEvaluationId, Model model) {
|
MallUserEvaluation mallUserEvaluation = mallUserEvaluationService.selectById(mallUserEvaluationId);
|
model.addAttribute("item", mallUserEvaluation);
|
return PREFIX + "mallUserEvaluation_detail.html";
|
}
|
}
|