记得上下班打卡 | git大法好,push需谨慎

Commit ecd6583b authored by GaoHu's avatar GaoHu

新增组织修改

parent 8d9dec38
package com.liquidnet.client.admin.framework.web.exception;
import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolationException;
import org.apache.shiro.authz.AuthorizationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.ModelAndView;
import com.liquidnet.client.admin.common.core.domain.AjaxResult;
......@@ -105,6 +109,24 @@ public class GlobalExceptionHandler
return AjaxResult.error(message);
}
/**
* MethodArgumentNotValidException
*/
/*@ExceptionHandler(MethodArgumentNotValidException.class)
public AjaxResult handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
String errMsg = e.getBindingResult().getFieldErrors().get(0).getDefaultMessage();
return AjaxResult.error(errMsg);
}*/
/**
* ConstraintViolationException
*/
/*@ExceptionHandler(ConstraintViolationException.class)
public AjaxResult handleConstraintViolationException(ConstraintViolationException e) {
String errMsg = e.getMessage().split(":")[1];
return AjaxResult.error(errMsg);
}*/
/**
* 演示模式异常
*/
......
......@@ -15,6 +15,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.InputStream;
......@@ -111,7 +112,7 @@ public class SmileUserController extends BaseController {
@ApiOperation("新增特邀代理")
@ResponseBody
@ApiOperationSupport(order = 3)
public AjaxResult saveInvitedAgent(SmileUserInvitedVo smileUserInvitedVo) {
public AjaxResult saveInvitedAgent(@Validated @RequestBody SmileUserInvitedVo smileUserInvitedVo) {
return iSmileUserService.saveInvitedAgent(smileUserInvitedVo);
}
......
......@@ -3,6 +3,8 @@ package com.liquidnet.client.admin.zhengzai.smile.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
/**
* <p>
*
......@@ -20,6 +22,7 @@ public class SmileOrganizationVo{
* 组织名称
*/
@ApiModelProperty(value = "组织名称", example = "")
@NotEmpty(message = "组织名称不能为空")
private String name;
/**
......
......@@ -2,7 +2,9 @@ package com.liquidnet.client.admin.zhengzai.smile.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NonNull;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
......@@ -13,17 +15,22 @@ import java.math.BigDecimal;
public class SmileUserInvitedVo {
@ApiModelProperty(value = "姓名")
@NotEmpty(message = "姓名不能为空")
private String name;
@ApiModelProperty(value = "手机号", example = "")
@NotEmpty(message = "手机号不能为空")
private String phone;
@ApiModelProperty(value = "代理描述")
@NotEmpty(message = "代理描述不能为空")
private String describe;
@ApiModelProperty(value = "演出id")
@NotEmpty(message = "演出id不能为空")
private String performancesId;
@ApiModelProperty(value = "票提")
@NotNull(message = "票提不能为空")
private BigDecimal ticket;
}
......@@ -2,6 +2,7 @@ package com.liquidnet.client.admin.zhengzai.smile.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
......@@ -96,6 +97,36 @@ public class SmileOrganizationServiceImpl extends ServiceImpl<SmileOrganizationM
BeanUtils.copyProperties(smileOrganizationVo, smileOrganization);
smileOrganization.setCreatedDate(LocalDateTime.now());
smileOrganization.setUpdatedDate(LocalDateTime.now());
//判断总代id是否为空
if (!StringUtils.isEmpty(smileOrganizationVo.getAgentId())){
//查询uid信息
SmileUserVO smileUserVO = smileRedisUtils.getSmileUserVO(smileOrganizationVo.getAgentId());
if (null==smileUserVO){
return AjaxResult.error("用户不存在");
}
if (smileUserVO.getType()==2){
//该用户可以配置为总代
smileOrganization.setAgentId(smileOrganizationVo.getAgentId());
smileOrganization.setDelTag(0);
smileOrganizationMapper.insert(smileOrganization);
//修改用户
LambdaQueryWrapper<SmileUser> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
userLambdaQueryWrapper.eq(SmileUser::getUid,smileOrganizationVo.getAgentId());
SmileUser smileUser = smileUserMapper.selectOne(userLambdaQueryWrapper);
smileUser.setAgentId(smileOrganizationVo.getAgentId());
smileUser.setOrgId(smileOrganization.getId());
smileUser.setType(1);
smileUserMapper.updateById(smileUser);
smileUserVO.setAgentId(smileUser.getAgentId());
smileUserVO.setOrgId(smileUser.getOrgId());
smileUserVO.setType(1);
smileRedisUtils.setSmileUserVO(smileUserVO.getUid(),smileUserVO);
return AjaxResult.success();
}else {
return AjaxResult.warn("该用户可为其他组织总代!");
}
}
smileOrganization.setDelTag(0);
smileOrganizationMapper.insert(smileOrganization);
return AjaxResult.success();
......
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