package cn.huge.module.ctuser.controller.web;
|
|
import cn.huge.base.common.utils.ReturnFailUtils;
|
import cn.huge.base.common.utils.ReturnSucUtils;
|
import cn.huge.module.ctuser.domain.po.CtUsepost;
|
import cn.huge.module.ctuser.service.CtUsepostService;
|
import com.google.common.collect.Maps;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.Sort;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.Map;
|
|
/**
|
* @title: 客户用户配岗表接口api-web端
|
* @description: 客户用户配岗表接口api-web端
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2024-08-19 20:04:19
|
* @version: 1.0.0
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/api/web/ctUsepost")
|
public class CtUsepostWebController {
|
|
@Autowired(required = false)
|
private HttpServletRequest request;
|
|
@Autowired
|
private CtUsepostService service;
|
|
/**
|
* 获取请求URL参数
|
* @return Map<String, Object>
|
*/
|
private Map<String, Object> getParameter(){
|
Map<String, Object> terms = Maps.newHashMap();
|
// 配岗编号
|
String id = request.getParameter("id");
|
if (StringUtils.isNotBlank(id)){
|
terms.put("id", id);
|
}
|
// 用户编号
|
String userId = request.getParameter("userId");
|
if (StringUtils.isNotBlank(userId)){
|
terms.put("userId", userId);
|
}
|
// 岗位编号
|
String postId = request.getParameter("postId");
|
if (StringUtils.isNotBlank(postId)){
|
terms.put("postId", postId);
|
}
|
// 岗位名称
|
String postName = request.getParameter("postName");
|
if (StringUtils.isNotBlank(postName)){
|
terms.put("postName", postName);
|
}
|
// 组织编号
|
String unitId = request.getParameter("unitId");
|
if (StringUtils.isNotBlank(unitId)){
|
terms.put("unitId", unitId);
|
}
|
// 部门编号
|
String deptId = request.getParameter("deptId");
|
if (StringUtils.isNotBlank(deptId)){
|
terms.put("deptId", deptId);
|
}
|
// 配岗类型,1:主岗,2:兼岗
|
String matchType = request.getParameter("matchType");
|
if (StringUtils.isNotBlank(matchType)){
|
terms.put("matchType", matchType);
|
}
|
// 所属客户编号
|
String custId = request.getParameter("custId");
|
if (StringUtils.isNotBlank(custId)){
|
terms.put("custId", custId);
|
}
|
// 创建时间区间
|
String createStart = request.getParameter("createStart");
|
String createEnd = request.getParameter("createEnd");
|
if(StringUtils.isNotBlank(createStart) && StringUtils.isNotBlank(createEnd)) {
|
terms.put("createStart", createStart);
|
terms.put("createEnd", createEnd);
|
}
|
// 更新时间区间
|
String updateStart = request.getParameter("updateStart");
|
String updateEnd = request.getParameter("updateEnd");
|
if(StringUtils.isNotBlank(updateStart) && StringUtils.isNotBlank(updateEnd)) {
|
terms.put("updateStart", updateStart);
|
terms.put("updateEnd", updateEnd);
|
}
|
return terms;
|
}
|
|
/**
|
* 条件查询多个
|
* @url {ctx}/api/web/ctUsepost/listQuery
|
* @return Object
|
*/
|
@GetMapping("/listQuery")
|
public Object listQuery() {
|
try {
|
Map<String, Object> terms = getParameter();
|
return ReturnSucUtils.getRepInfo(service.listTerms(terms));
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 条件分页查询
|
* @url {ctx}/api/web/ctUsepost/pageQuery
|
* @param page 页码
|
* @param size 每页数量
|
* @return Object
|
*/
|
@GetMapping("/pageQuery")
|
public Object pageQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) {
|
try {
|
Map<String, Object> terms = getParameter();
|
Sort sort = Sort.by(Sort.Direction.DESC, "create_time");
|
PageRequest pageRequest = PageRequest.of(page-1, size, sort);
|
Page<CtUsepost> ctUsepostPage = service.pageQuery(pageRequest, terms);
|
return ReturnSucUtils.getRepInfo( "处理成功", ctUsepostPage);
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 根据编号查询单个
|
* @url {ctx}/api/web/ctUsepost/getById
|
* @param id 主键编号
|
* @return Object
|
*/
|
@GetMapping("/getById")
|
public Object getById(@RequestParam(value = "id") String id) {
|
try {
|
return ReturnSucUtils.getRepInfo(service.getById(id));
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 根据主键单个
|
* @url {ctx}/api/web/ctUsepost/deleteById
|
* @param id 主键编号
|
* @return Object
|
*/
|
@GetMapping("/deleteById")
|
public Object deleteById(@RequestParam(value = "id") String id) {
|
try {
|
service.removeById(id);
|
return ReturnSucUtils.getRepInfo();
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 新增或更新对象
|
* @url {ctx}/api/web/ctUsepost/saveCtUsepost
|
* @param ctUsepost 实体对象
|
* @return Object
|
*/
|
@PostMapping("/saveCtUsepost")
|
public Object saveCtUsepost(@RequestBody CtUsepost ctUsepost) {
|
try {
|
service.saveCtUsepost(ctUsepost);
|
return ReturnSucUtils.getRepInfo();
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
}
|