package com.stylefeng.guns.modular.newlyAdded;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.stylefeng.guns.core.util.DateUtil;
|
import com.stylefeng.guns.modular.system.dao.UserInfoMapper;
|
import com.stylefeng.guns.modular.system.dao.UserMapper;
|
import com.stylefeng.guns.modular.system.model.*;
|
import com.stylefeng.guns.modular.system.service.*;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.apache.commons.lang.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import java.math.BigDecimal;
|
import java.util.Calendar;
|
import java.util.Date;
|
import java.util.List;
|
|
@Api("新增2.0")
|
@RestController
|
@RequestMapping("")
|
public class NewlyAddedController {
|
|
|
|
@Autowired
|
private IDriverService driverService;
|
|
|
@Autowired
|
private ITbCarRentalService carRentalService;
|
|
@Autowired
|
private ITbCommentService commentService;
|
|
@Autowired
|
private ITbSellingCarService sellingCarService;
|
|
@Autowired
|
private ITbRecruitService recruitService;
|
|
@Autowired
|
private ITbShowModularService showModularService;
|
|
|
@Resource
|
private UserInfoMapper userInfoMapper;
|
|
|
@Autowired
|
private ITbMessNumService messNumService;
|
|
|
@Autowired
|
private ICompanyService companyService;
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getCommentList")
|
@ApiOperation(value = "获取评论列表", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码(首页1)", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "类型(1=租车,2=卖车,3=招聘)", name = "type", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "对应类型id", name = "orderId", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbComment>> getCommentList(Integer pageNum, Integer size, HttpServletRequest request
|
,Integer type
|
,Integer orderId){
|
pageNum = (pageNum - 1) * size;
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
List<TbComment> list = commentService.getList(type,orderId,null,pageNum,size);
|
for(TbComment comment:list){
|
comment.setReplyCommentList(commentService.getList(type,orderId,comment.getId(),pageNum,size));
|
}
|
return ResultUtil.success(list);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getRecruitDetail")
|
@ApiOperation(value = "获取招聘详情", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "id", name = "id", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<TbRecruit> getRecruitDetail(Integer id, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
TbRecruit recruit = recruitService.selectById(id);
|
//封装公司信息
|
if(recruit.getCompanyType()==1){
|
Company company = companyService.selectById(recruit.getCompanyId());
|
recruit.setCompanyName(company.getName());
|
recruit.setCompanyInfo(company.getCompanyInfo());
|
recruit.setDetailAddress(company.getDetailAddress());
|
recruit.setScale(company.getScale());
|
}
|
return ResultUtil.success(recruit);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getRecruitFirstPageList")
|
@ApiOperation(value = "获取招聘列表-首页推荐", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbRecruit>> getRecruitFirstPageList(HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
Wrapper wrapper = new EntityWrapper<TbRecruit>().eq("status",2).eq("firstPageShow",1).orderBy("id",false);
|
return ResultUtil.success(recruitService.selectList(wrapper));
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getRecruitList")
|
@ApiOperation(value = "获取招聘列表", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码(首页1)", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "司机类型", name = "driverType", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "福利", name = "welfare", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "开始薪资", name = "startSalary", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "结束薪资", name = "endSalary", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "搜索", name = "serachName", required = false, dataType = "String"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbRecruit>> getRecruitList(Integer pageNum, Integer size, HttpServletRequest request
|
,String driverType
|
,String welfare
|
,BigDecimal startSalary
|
,BigDecimal endSalary
|
,String serachName){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
Page<TbRecruit> page = new Page<>();
|
page.setSize(size);
|
page.setCurrent(pageNum);
|
Wrapper wrapper = new EntityWrapper<TbRecruit>().eq("status",2).orderBy("id",false);
|
if(StringUtils.isNotEmpty(driverType)){
|
wrapper.and("FIND_IN_SET('"+driverType+"',(driverType))");
|
}
|
if(StringUtils.isNotEmpty(welfare)){
|
String[] strList = welfare.split(",");
|
String welfareStr = "(";
|
for(int i=0;i<strList.length;i++){
|
if(i==strList.length-1){
|
welfareStr+="FIND_IN_SET('"+strList[i]+"',(welfare)) ";
|
}else{
|
welfareStr+="FIND_IN_SET('"+strList[i]+"',(welfare)) or ";
|
}
|
|
}
|
welfareStr+=")";
|
wrapper.and(welfareStr);
|
}
|
if(StringUtils.isNotEmpty(serachName)){
|
wrapper.like("title",serachName);
|
}
|
if(startSalary!=null){
|
wrapper.ge("startSalary",startSalary);
|
}
|
if(endSalary!=null){
|
wrapper.le("endSalary",endSalary);
|
}
|
return ResultUtil.success(recruitService.selectPage(page,wrapper).getRecords());
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getMessNum")
|
@ApiOperation(value = "获取消息数量", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<TbMessNum> getMessNum(HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
TbMessNum messNum = messNumService.selectOne(new EntityWrapper<TbMessNum>().eq("userType",2).eq("userId",uid));
|
if(messNum==null){
|
messNum = new TbMessNum();
|
messNum.setCommentNum(0);
|
messNum.setCarRental(0);
|
messNum.setSellingCarNum(0);
|
messNum.setUserId(uid);
|
messNum.setUserType(2);
|
messNum.insert();
|
}
|
return ResultUtil.success(messNum);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getShowModular")
|
@ApiOperation(value = "获取显示模块设置", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbShowModular>> getShowModular(HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
return ResultUtil.success(showModularService.selectList(null));
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/insertOrUpdateCarRental")
|
@ApiOperation(value = "添加/编辑租车", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil insertOrUpdateCarRental(TbCarRental carRental, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
if(carRental.getId()==null){
|
carRental.setCreateTime(new Date());
|
}
|
carRental.setStatus(1);
|
carRental.setUserType(2);
|
carRental.setUserId(uid);
|
carRentalService.insertOrUpdate(carRental);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getMyCarRentalList")
|
@ApiOperation(value = "获取我的租车列表", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码(首页1)", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbCarRental>> getMyCarRentalList(Integer pageNum, Integer size, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
TbMessNum messNum = messNumService.selectOne(new EntityWrapper<TbMessNum>().eq("userType",2).eq("userId",uid));
|
if(messNum==null){
|
messNum = new TbMessNum();
|
messNum.setCommentNum(0);
|
messNum.setCarRental(0);
|
messNum.setSellingCarNum(0);
|
messNum.setUserId(uid);
|
messNum.setUserType(2);
|
messNum.insert();
|
}else{
|
messNum.setCarRental(0);
|
messNum.updateById();
|
}
|
Page<TbCarRental> page = new Page<>();
|
page.setSize(size);
|
page.setCurrent(pageNum);
|
return ResultUtil.success(carRentalService.selectPage(page,new EntityWrapper<TbCarRental>().eq("userType",2)
|
.eq("userId",uid).ne("status",6).orderBy("status",true)).getRecords());
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getCarRentalFirstPageList")
|
@ApiOperation(value = "获取租车列表-首页推荐", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbCarRental>> getCarRentalFirstPageList(HttpServletRequest request
|
){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
Wrapper wrapper = new EntityWrapper<TbCarRental>().eq("status",2).eq("firstPageShow",1).orderBy("id",false);
|
return ResultUtil.success(carRentalService.selectList(wrapper));
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getCarRentalList")
|
@ApiOperation(value = "获取租车列表", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码(首页1)", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "车辆品牌id", name = "brandId", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "类型(1=个人,2=企业)", name = "type", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "省份code", name = "provinceCode", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "城市code", name = "cityCode", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "取件证件", name = "pickUpCarCarCertificates", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "开始租金", name = "startRentMoney", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "结束租金", name = "endRentMoney", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "搜索", name = "serachName", required = false, dataType = "String"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbCarRental>> getCarRentalList(Integer pageNum, Integer size, HttpServletRequest request
|
,Integer brandId
|
,Integer type,String provinceCode,String cityCode,String pickUpCarCarCertificates,Double startRentMoney,Double endRentMoney
|
,String serachName
|
){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
Page<TbCarRental> page = new Page<>();
|
page.setSize(size);
|
page.setCurrent(pageNum);
|
Wrapper wrapper = new EntityWrapper<TbCarRental>().eq("status",2).orderBy("id",false);
|
if(StringUtils.isNotEmpty(pickUpCarCarCertificates)){
|
wrapper.and("FIND_IN_SET('"+pickUpCarCarCertificates+"',(pickUpCarCarCertificates))");
|
}
|
if(brandId!=null){
|
wrapper.eq("brandId",brandId);
|
}
|
if(type!=null){
|
if(type==1){
|
wrapper.le("userType",2);
|
}else{
|
wrapper.ge("userType",3);
|
}
|
}
|
if(cityCode!=null){
|
wrapper.eq("cityCode",cityCode);
|
}
|
if(provinceCode!=null){
|
wrapper.eq("provinceCode",provinceCode);
|
}
|
if(StringUtils.isNotEmpty(serachName)){
|
wrapper.like("title",serachName);
|
}
|
if(startRentMoney!=null){
|
wrapper.ge("rentMoney",startRentMoney);
|
}
|
if(endRentMoney!=null){
|
wrapper.le("rentMoney",endRentMoney);
|
}
|
return ResultUtil.success(carRentalService.selectPage(page,wrapper).getRecords());
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getCarRentalDetail")
|
@ApiOperation(value = "获取租车详情", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "id", name = "id", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<TbCarRental> getCarRentalDetail(Integer id, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
TbCarRental tbCarRental = carRentalService.selectById(id);
|
if(tbCarRental.getUserType()==1)tbCarRental.setIsAuth(userInfoMapper.selectById(tbCarRental.getUserId()).getIsAuth());
|
return ResultUtil.success(tbCarRental);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/insertOrUpdateSellingCar")
|
@ApiOperation(value = "添加/编辑卖车", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil insertOrUpdateSellingCar(TbSellingCar sellingCar, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
if(sellingCar.getId()==null){
|
sellingCar.setCreateTime(new Date());
|
}
|
sellingCar.setStatus(1);
|
sellingCar.setUserType(2);
|
sellingCar.setUserId(uid);
|
sellingCarService.insertOrUpdate(sellingCar);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getSellingCarFirstPageList")
|
@ApiOperation(value = "获取卖车列表-首页推荐", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbSellingCar>> getSellingCarFirstPageList(HttpServletRequest request
|
){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
Wrapper wrapper = new EntityWrapper<TbSellingCar>().eq("status",2).eq("firstPageShow",1).orderBy("id",false);
|
return ResultUtil.success(sellingCarService.selectList(wrapper));
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getSellingCarList")
|
@ApiOperation(value = "获取卖车列表", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码(首页1)", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "车辆品牌id", name = "brandId", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "类型(1=个人,2=企业)", name = "type", required = false, dataType = "int"),
|
@ApiImplicitParam(value = "省份code", name = "provinceCode", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "城市code", name = "cityCode", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "变速箱", name = "transmissionCase", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "开始金额", name = "startTransferPrice", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "结束金额", name = "endTransferPrice", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "开始里程", name = "startMileage", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "结束里程", name = "endMileage", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "开始排量", name = "startDisplacement", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "结束排量", name = "endDisplacement", required = false, dataType = "double"),
|
@ApiImplicitParam(value = "开始时间", name = "startLicensingTime", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "结束时间", name = "endLicensingTime", required = false, dataType = "String"),
|
@ApiImplicitParam(value = "搜索", name = "serachName", required = false, dataType = "String"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbSellingCar>> getSellingCarList(Integer pageNum, Integer size, HttpServletRequest request
|
,Integer brandId
|
,Integer type,String provinceCode,String cityCode,String transmissionCase,Double startTransferPrice,Double endTransferPrice
|
,Double startMileage,Double endMileage
|
,Double startDisplacement,Double endDisplacement
|
,String startLicensingTime,String endLicensingTime
|
,String serachName
|
){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
Page<TbSellingCar> page = new Page<>();
|
page.setSize(size);
|
page.setCurrent(pageNum);
|
Wrapper wrapper = new EntityWrapper<TbSellingCar>().eq("status",2).orderBy("id",false);
|
if(StringUtils.isNotEmpty(transmissionCase)){
|
wrapper.eq("transmissionCase",transmissionCase);
|
}
|
Calendar c = Calendar.getInstance();
|
c.setTime(new Date());
|
if(StringUtils.isNotEmpty(startLicensingTime)){
|
c.add(Calendar.YEAR, -Integer.parseInt(startLicensingTime));
|
Date y = c.getTime();
|
wrapper.le("licensingTime",DateUtil.format(y,"yyyy-MM-dd"));
|
}
|
if(StringUtils.isNotEmpty(endLicensingTime)){
|
c.add(Calendar.YEAR, -Integer.parseInt(endLicensingTime));
|
Date y = c.getTime();
|
wrapper.ge("licensingTime",DateUtil.format(y,"yyyy-MM-dd"));
|
}
|
if(brandId!=null){
|
wrapper.eq("brandId",brandId);
|
}
|
if(type!=null){
|
if(type==1){
|
wrapper.le("userType",2);
|
}else{
|
wrapper.eq("userType",3);
|
}
|
|
}
|
if(cityCode!=null){
|
wrapper.eq("cityCode",cityCode);
|
}
|
|
if(provinceCode!=null){
|
wrapper.eq("provinceCode",provinceCode);
|
}
|
if(StringUtils.isNotEmpty(serachName)){
|
wrapper.like("title",serachName);
|
}
|
if(startTransferPrice!=null){
|
wrapper.ge("transferPrice",startTransferPrice);
|
}
|
if(endTransferPrice!=null){
|
wrapper.le("transferPrice",endTransferPrice);
|
}
|
|
if(startMileage!=null){
|
wrapper.ge("mileage",startMileage);
|
}
|
if(endMileage!=null){
|
wrapper.le("mileage",endMileage);
|
}
|
|
|
if(startDisplacement!=null){
|
wrapper.ge("displacement",startDisplacement);
|
}
|
if(endDisplacement!=null){
|
wrapper.le("displacement",endDisplacement);
|
}
|
return ResultUtil.success(sellingCarService.selectPage(page,wrapper).getRecords());
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getMySellingCarList")
|
@ApiOperation(value = "获取我的卖车列表", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码(首页1)", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbSellingCar>> getMySellingCarList(Integer pageNum, Integer size, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
TbMessNum messNum = messNumService.selectOne(new EntityWrapper<TbMessNum>().eq("userType",2).eq("userId",uid));
|
if(messNum==null){
|
messNum = new TbMessNum();
|
messNum.setCommentNum(0);
|
messNum.setCarRental(0);
|
messNum.setSellingCarNum(0);
|
messNum.setUserId(uid);
|
messNum.setUserType(2);
|
messNum.insert();
|
}else{
|
messNum.setSellingCarNum(0);
|
messNum.updateById();
|
}
|
Page<TbSellingCar> page = new Page<>();
|
page.setSize(size);
|
page.setCurrent(pageNum);
|
return ResultUtil.success(sellingCarService.selectPage(page,new EntityWrapper<TbSellingCar>().eq("userType",2)
|
.eq("userId",uid).ne("status",6).orderBy("status",true)).getRecords());
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getSellingCarDetail")
|
@ApiOperation(value = "获取卖车详情", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "id", name = "id", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<TbSellingCar> getSellingCarDetail(Integer id, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
TbSellingCar sellingCar = sellingCarService.selectById(id);
|
if(sellingCar.getUserType()==1)sellingCar.setIsAuth(userInfoMapper.selectById(sellingCar.getUserId()).getIsAuth());
|
return ResultUtil.success(sellingCar);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/insertComment")
|
@ApiOperation(value = "添加评论", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil insertComment(TbComment comment, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
comment.setUserType(2);
|
comment.setUserId(uid);
|
comment.setCreateTime(new Date());
|
if(comment.getType()==1){
|
comment.setOrderInfo(JSONObject.toJSONString(carRentalService.selectById(comment.getOrderId())));
|
}else if(comment.getType()==2){
|
comment.setOrderInfo(JSONObject.toJSONString(sellingCarService.selectById(comment.getOrderId())));
|
|
}else{
|
comment.setOrderInfo(JSONObject.toJSONString(recruitService.selectById(comment.getOrderId())));
|
}
|
if(comment.getCommentId()!=null){
|
TbComment comment1 = commentService.selectById(comment.getCommentId());
|
if(comment1.getPid()==null || comment1.getPid().equals("")){
|
comment.setPid(comment.getCommentId());
|
}else{
|
comment.setPid(comment1.getPid());
|
}
|
comment.setReplyUserType(comment1.getUserType());
|
comment.setReplyUserId(comment1.getUserId());
|
TbMessNum messNum = messNumService.selectOne(new EntityWrapper<TbMessNum>().eq("userType",comment1.getUserType()).eq("userId",comment1.getUserId()));
|
if(messNum==null){
|
messNum = new TbMessNum();
|
messNum.setCommentNum(1);
|
messNum.setCarRental(0);
|
messNum.setSellingCarNum(0);
|
messNum.setUserId(comment1.getUserId());
|
messNum.setUserType(comment1.getUserType());
|
messNum.insert();
|
}else{
|
messNum.setCommentNum(messNum.getCommentNum()+1);
|
messNum.setUserId(comment1.getUserId());
|
messNum.setUserType(comment1.getUserType());
|
messNum.updateById();
|
}
|
if(comment.getReplyUserType()==1){
|
UserInfo userInfo = userInfoMapper.selectById(comment1.getUserId());
|
comment.setReplyUserAvatar(userInfo.getAvatar());
|
comment.setReplyUserName(userInfo.getName());
|
}else{
|
Driver driver = driverService.selectById(comment1.getUserId());
|
comment.setReplyUserAvatar(driver.getHeadImgUrl());
|
comment.setReplyUserName(driver.getName());
|
}
|
}
|
comment.insert();
|
Driver driver = driverService.selectById(uid);
|
comment.setUserAvatar(driver.getHeadImgUrl());
|
comment.setUserName(driver.getName());
|
return ResultUtil.success(comment);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getMyCommentList")
|
@ApiOperation(value = "获取我的评价列表", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码(首页1)", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbComment>> getMyCommentList(Integer pageNum, Integer size, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
Page<TbComment> page = new Page<>();
|
page.setSize(size);
|
page.setCurrent(pageNum);
|
return ResultUtil.success(commentService.selectPage(page,new EntityWrapper<TbComment>().eq("userType",2)
|
.eq("userId",uid).isNull("commentId").eq("isDetele",1).orderBy("id",false)).getRecords());
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/getMyReplyCommentList")
|
@ApiOperation(value = "获取我的回复列表", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "页码(首页1)", name = "pageNum", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil<List<TbComment>> getMyReplyCommentList(Integer pageNum, Integer size, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
TbMessNum messNum = messNumService.selectOne(new EntityWrapper<TbMessNum>().eq("userType",2).eq("userId",uid));
|
if(messNum==null){
|
messNum = new TbMessNum();
|
messNum.setCommentNum(0);
|
messNum.setCarRental(0);
|
messNum.setSellingCarNum(0);
|
messNum.setUserId(uid);
|
messNum.setUserType(2);
|
messNum.insert();
|
}else{
|
messNum.setCommentNum(0);
|
messNum.updateById();
|
}
|
Page<TbComment> page = new Page<>();
|
page.setSize(size);
|
page.setCurrent(pageNum);
|
List<TbComment> list = commentService.selectPage(page,new EntityWrapper<TbComment>().eq("replyUserType",2)
|
.eq("replyUserId",uid).eq("isDetele",1).orderBy("id",false)).getRecords();
|
for(TbComment comment:list){
|
if(comment.getUserType()==1){
|
comment.setUserName(userInfoMapper.selectById(comment.getUserId()).getNickName());
|
}else{
|
comment.setUserName(driverService.selectById(comment.getUserId()).getName());
|
}
|
TbComment comment1 = commentService.selectById(comment.getCommentId());
|
comment.setReplyUserContent(comment1.getContent());
|
if(comment.getReplyUserType()==1){
|
comment.setReplyUserName(userInfoMapper.selectById(comment1.getUserId()).getNickName());
|
}else{
|
comment.setReplyUserName(driverService.selectById(comment1.getUserId()).getName());
|
}
|
|
}
|
return ResultUtil.success(list);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/putOnTheShelf")
|
@ApiOperation(value = "上架", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "id", name = "id", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "类型(1=租车,2=卖车)", name = "type", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil putOnTheShelf(Integer type, Integer id, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
if(type==1){
|
TbCarRental carRental = new TbCarRental();
|
carRental.setId(id);
|
carRental.setStatus(2);
|
carRentalService.updateById(carRental);
|
}else{
|
|
TbSellingCar sellingCar = new TbSellingCar();
|
sellingCar.setId(id);
|
sellingCar.setStatus(2);
|
sellingCarService.updateById(sellingCar);
|
}
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/offTheShelf")
|
@ApiOperation(value = "下架", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "id", name = "id", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "类型(1=租车,2=卖车)", name = "type", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil offTheShelf(Integer type, Integer id, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
if(type==1){
|
TbCarRental carRental = new TbCarRental();
|
carRental.setId(id);
|
carRental.setStatus(3);
|
carRentalService.updateById(carRental);
|
}else{
|
|
TbSellingCar sellingCar = new TbSellingCar();
|
sellingCar.setId(id);
|
sellingCar.setStatus(3);
|
sellingCarService.updateById(sellingCar);
|
}
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/delete")
|
@ApiOperation(value = "删除", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "id", name = "id", required = true, dataType = "int"),
|
@ApiImplicitParam(value = "类型(1=租车,2=卖车)", name = "type", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil delete(Integer type, Integer id, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
if(type==1){
|
TbCarRental carRental = new TbCarRental();
|
carRental.setId(id);
|
carRental.setStatus(6);
|
carRentalService.updateById(carRental);
|
}else{
|
|
TbSellingCar sellingCar = new TbSellingCar();
|
sellingCar.setId(id);
|
sellingCar.setStatus(6);
|
sellingCarService.updateById(sellingCar);
|
}
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
@ResponseBody
|
@PostMapping("/api/newlyAdded/deleteComment")
|
@ApiOperation(value = "删除评论", tags = {"司机端-2.0新增"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "id", name = "id", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResultUtil deleteComment(Integer id, HttpServletRequest request){
|
try {
|
Integer uid = driverService.getUserIdFormRedis(request);
|
if(null == uid){
|
return ResultUtil.tokenErr();
|
}
|
TbComment tbComment = new TbComment();
|
tbComment.setId(id);
|
tbComment.setIsDetele(2);
|
commentService.updateById(tbComment);
|
return ResultUtil.success();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
}
|