5 changed files with 155 additions and 0 deletions
@ -0,0 +1,75 @@ |
|||||
|
package com.qs.serve.modules.thirty; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.AuthContextUtils; |
||||
|
import com.qs.serve.common.util.CodeGenUtil; |
||||
|
import com.qs.serve.common.util.CopierUtil; |
||||
|
import com.qs.serve.modules.sys.entity.SysDept; |
||||
|
import com.qs.serve.modules.sys.entity.SysUser; |
||||
|
import com.qs.serve.modules.sys.service.SysDeptService; |
||||
|
import com.qs.serve.modules.sys.service.SysUserService; |
||||
|
import com.qs.serve.modules.thirty.entity.VisitThemeThirtyParam; |
||||
|
import com.qs.serve.modules.visit.entity.VisitTheme; |
||||
|
import com.qs.serve.modules.visit.service.impl.VisitThemeServiceImpl; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
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.RestController; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
|
||||
|
/** |
||||
|
* 第三方接口 来访 |
||||
|
* @author YenHex |
||||
|
* @since 2024/11/12 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/thirty") |
||||
|
public class ThirtyVisitController { |
||||
|
|
||||
|
private VisitThemeServiceImpl visitThemeService; |
||||
|
private SysUserService sysUserService; |
||||
|
private SysDeptService sysDeptService; |
||||
|
|
||||
|
/** |
||||
|
* 新增 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/saveTheme") |
||||
|
@SysLog(module = SystemModule.VISIT, title = "拜访", biz = BizType.INSERT) |
||||
|
public R<?> save(@RequestBody @Valid VisitThemeThirtyParam param){ |
||||
|
VisitTheme entity = CopierUtil.copy(param,new VisitTheme()); |
||||
|
SysUser sysUser = sysUserService.getByAccount(param.getUserCode()); |
||||
|
if(sysUser==null){ |
||||
|
return R.error("用户编码无效或未被收录"); |
||||
|
} |
||||
|
entity.setUserId(sysUser.getId()); |
||||
|
entity.setUserCode(sysUser.getCode()); |
||||
|
entity.setUserName(sysUser.getName()); |
||||
|
SysDept dept = sysDeptService.getOne(new LambdaQueryWrapper<SysDept>() |
||||
|
.eq(SysDept::getCode,param.getDeptCode()),false); |
||||
|
if(dept==null){ |
||||
|
return R.error("部门编码无效或未被收录"); |
||||
|
} |
||||
|
entity.setDeptId(dept.getId()); |
||||
|
entity.setDeptName(dept.getName()); |
||||
|
|
||||
|
entity.setThemeCode("TP"+ CodeGenUtil.getDataCode(CodeGenUtil.SourceDataKey.VISIT)); |
||||
|
entity.setUserId(sysUser.getId()); |
||||
|
entity.setUserCode(sysUser.getCode()); |
||||
|
entity.setUserName(sysUser.getName()); |
||||
|
|
||||
|
boolean result = visitThemeService.save(entity); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
package com.qs.serve.modules.thirty.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.FieldFill; |
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import java.time.LocalDate; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/11/12 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class VisitThemeThirtyParam { |
||||
|
|
||||
|
/** 拜访主题 */ |
||||
|
@NotNull(message = "拜访主题不能为空") |
||||
|
private String themeTitle; |
||||
|
|
||||
|
/** 部门编码 */ |
||||
|
@NotNull(message = "部门昵称不能为空") |
||||
|
private String deptCode; |
||||
|
|
||||
|
/** 用户编码 */ |
||||
|
@NotNull(message = "用户编码不能为空") |
||||
|
private String userCode; |
||||
|
|
||||
|
/** 接待地点 */ |
||||
|
@NotNull(message = "接待地点不能为空") |
||||
|
private String userRoom; |
||||
|
|
||||
|
/** 来访开始时间 */ |
||||
|
@NotNull(message = "来访开始时间不能为空") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private LocalDateTime visitStartDate; |
||||
|
|
||||
|
/** 来访结束时间 */ |
||||
|
@NotNull(message = "来访结束时间不能为空") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private LocalDateTime visitEndDate; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
@Length(max = 255,message = "备注长度不能超过255字") |
||||
|
private String remark; |
||||
|
|
||||
|
} |
Loading…
Reference in new issue