基础管理
This commit is contained in:
parent
7d1eea98f4
commit
838cd2ae71
|
|
@ -33,6 +33,9 @@ public enum HttpCodeEnum {
|
|||
INVALID_LONGITUDE_FORMAT(1001, "经度格式不正确"),
|
||||
INVALID_LATITUDE_FORMAT(1002, "纬度格式不正确"),
|
||||
INVALID_PHONE_FORMAT(1003, "手机号格式不正确"),
|
||||
INVALID_PHONE_NUMBER_FORMAT(501, "手机号格式不正确"),
|
||||
UPDATE_TO_DATABASE(500, "操作失败,请联系管理员"),
|
||||
DEPART_IS_RELATED_TEAM(1004, "该项目部下有关联班组,不允许删除"),
|
||||
REPEATE_ERROR(600, "不允许重复提交,请稍候再试");
|
||||
|
||||
private final int code;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,114 @@
|
|||
package com.bonus.material.basic.controller;
|
||||
|
||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.basic.domain.BmProDepart;
|
||||
import com.bonus.material.basic.service.BmProDepartService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author ma_sh
|
||||
* @create 2025/5/12 10:06
|
||||
*/
|
||||
@Api(tags = "项目部管理接口")
|
||||
@RestController
|
||||
@RequestMapping("/bmProDepart")
|
||||
@Slf4j
|
||||
public class BmProDepartController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private BmProDepartService bmProDepartService;
|
||||
|
||||
/**
|
||||
* 查询项目部列表信息
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页查询项目部信息")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult queryByPage(BmProDepart tbProDepart) {
|
||||
try {
|
||||
if (tbProDepart.getIsAll() != null && tbProDepart.getIsAll() == 0) {
|
||||
return AjaxResult.success(bmProDepartService.queryByPage(tbProDepart));
|
||||
}
|
||||
startPage();
|
||||
List<BmProDepart> list = bmProDepartService.queryByPage(tbProDepart);
|
||||
return AjaxResult.success(getDataTable(list));
|
||||
} catch (Exception e) {
|
||||
log.error("查询项目部数据失败", e);
|
||||
return AjaxResult.error("项目部数据查询失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增项目部
|
||||
*
|
||||
* @param tbProDepart 实体
|
||||
* @return 新增结果
|
||||
*/
|
||||
@ApiOperation(value = "新增项目部数据")
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody BmProDepart tbProDepart) {
|
||||
try {
|
||||
return bmProDepartService.insert(tbProDepart);
|
||||
} catch (Exception e) {
|
||||
log.error("新增项目部数据失败", e);
|
||||
return AjaxResult.error("新增项目部数据失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑项目部
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "编辑项目部数据")
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody BmProDepart tbProDepart) {
|
||||
try {
|
||||
return bmProDepartService.update(tbProDepart);
|
||||
} catch (Exception e) {
|
||||
log.error("编辑项目部数据失败", e);
|
||||
return AjaxResult.error("编辑项目部数据失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除项目部
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除项目部数据")
|
||||
@PostMapping("/delete")
|
||||
public AjaxResult deleteById(@RequestBody BmProDepart tbProDepart) {
|
||||
try {
|
||||
return bmProDepartService.deleteById(tbProDepart);
|
||||
} catch (Exception e) {
|
||||
log.error("删除项目部数据失败", e);
|
||||
return AjaxResult.error("删除项目部数据失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出项目部管理列表
|
||||
* @param response
|
||||
* @param tbProDepart
|
||||
*/
|
||||
@ApiOperation(value = "导出项目部管理列表")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, BmProDepart tbProDepart)
|
||||
{
|
||||
List<BmProDepart> list = bmProDepartService.queryByPage(tbProDepart);
|
||||
ExcelUtil<BmProDepart> util = new ExcelUtil<BmProDepart>(BmProDepart.class);
|
||||
util.exportExcel(response, list, "项目部管理数据");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
package com.bonus.material.basic.controller;
|
||||
|
||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.basic.domain.BmTeam;
|
||||
import com.bonus.material.basic.service.BmTeamService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author ma_sh
|
||||
* @create 2025/5/12 13:02
|
||||
*/
|
||||
@Api(tags = "班组管理接口")
|
||||
@RestController
|
||||
@RequestMapping("/bmTeam")
|
||||
@Slf4j
|
||||
public class BmTeamController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private BmTeamService bmTeamService;
|
||||
|
||||
/**
|
||||
* 查询班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页查询班组信息")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult queryByPage(BmTeam tbTeam) {
|
||||
try {
|
||||
if (tbTeam.getIsAll() != null && tbTeam.getIsAll() == 0) {
|
||||
return AjaxResult.success(bmTeamService.queryByPage(tbTeam));
|
||||
}
|
||||
startPage();
|
||||
List<BmTeam> list = bmTeamService.queryByPage(tbTeam);
|
||||
return AjaxResult.success(getDataTable(list));
|
||||
} catch (Exception e) {
|
||||
log.error("查询班组数据失败", e);
|
||||
return AjaxResult.error("班组数据查询失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "新增班组信息")
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody BmTeam tbTeam) {
|
||||
try {
|
||||
return bmTeamService.insert(tbTeam);
|
||||
} catch (Exception e) {
|
||||
log.error("新增班组数据失败", e);
|
||||
return AjaxResult.error("新增班组数据失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "编辑班组信息")
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody BmTeam tbTeam) {
|
||||
try {
|
||||
return bmTeamService.edit(tbTeam);
|
||||
} catch (Exception e) {
|
||||
log.error("编辑班组数据失败", e);
|
||||
return AjaxResult.error("编辑班组数据失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "删除班组数据")
|
||||
@PostMapping("/delete")
|
||||
public AjaxResult deleteById(@RequestBody BmTeam tbTeam) {
|
||||
try {
|
||||
return bmTeamService.deleteById(tbTeam);
|
||||
} catch (Exception e) {
|
||||
log.error("删除班组信息失败", e);
|
||||
return AjaxResult.error("删除班组信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出班组管理列表
|
||||
* @param response
|
||||
* @param tbTeam
|
||||
*/
|
||||
@ApiOperation(value = "导出班组管理列表")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, BmTeam tbTeam)
|
||||
{
|
||||
List<BmTeam> list = bmTeamService.queryByPage(tbTeam);
|
||||
ExcelUtil<BmTeam> util = new ExcelUtil<BmTeam>(BmTeam.class);
|
||||
util.exportExcel(response, list, "班组管理数据");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
package com.bonus.material.basic.domain;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 项目部管理
|
||||
* @Author ma_sh
|
||||
* @create 2025/5/12 10:07
|
||||
*/
|
||||
@Data
|
||||
public class BmProDepart {
|
||||
|
||||
/**
|
||||
* 是否下拉选
|
||||
*/
|
||||
private Integer isAll;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 项目部名称
|
||||
*/
|
||||
@Excel(name = "项目部名称")
|
||||
private String departName;
|
||||
|
||||
/**
|
||||
* 所属组织id
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 所属组织
|
||||
*/
|
||||
@Excel(name = "所属组织")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
@Excel(name = "联系人")
|
||||
private String headUser;
|
||||
|
||||
/**
|
||||
* 负责人联系电话(sm4)加密(查询展示脱敏)
|
||||
*/
|
||||
@Excel(name = "联系电话")
|
||||
private String headUserPhone;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createUser;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private Long updateUser;
|
||||
|
||||
/**
|
||||
* 是否删除(0, 正常 2删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 关键字
|
||||
*/
|
||||
private String keyWord;
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package com.bonus.material.basic.domain;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 班组管理
|
||||
* @Author ma_sh
|
||||
* @create 2025/5/12 10:07
|
||||
*/
|
||||
@Data
|
||||
public class BmTeam {
|
||||
|
||||
/**
|
||||
* 是否下拉选
|
||||
*/
|
||||
private Integer isAll;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目部名称
|
||||
*/
|
||||
@Excel(name = "班组名称")
|
||||
private String teamName;
|
||||
|
||||
/**
|
||||
* 所属项目部id
|
||||
*/
|
||||
private Long departId;
|
||||
|
||||
/**
|
||||
* 所属项目部
|
||||
*/
|
||||
@Excel(name = "所属项目部")
|
||||
private String departName;
|
||||
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
@Excel(name = "联系人")
|
||||
private String relName;
|
||||
|
||||
/**
|
||||
* 负责人联系电话(sm4)加密(查询展示脱敏)
|
||||
*/
|
||||
@Excel(name = "联系电话")
|
||||
private String relPhone;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createUser;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private Long updateUser;
|
||||
|
||||
/**
|
||||
* 是否删除(0, 正常 2删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 关键字
|
||||
*/
|
||||
private String keyWord;
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.bonus.material.basic.mapper;
|
||||
|
||||
import com.bonus.material.basic.domain.BmProDepart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName BmProDepartMapper
|
||||
* @Author ma_sh
|
||||
* @create 2025/5/12 10:14
|
||||
*/
|
||||
public interface BmProDepartMapper {
|
||||
|
||||
/**
|
||||
* 查询项目部列表信息
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
List<BmProDepart> queryByPage(BmProDepart tbProDepart);
|
||||
|
||||
/**
|
||||
* 按照名称查询
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
BmProDepart selectByName(BmProDepart tbProDepart);
|
||||
|
||||
/**
|
||||
* 新增项目部信息
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
int insert(BmProDepart tbProDepart);
|
||||
|
||||
/**
|
||||
* 修改项目部信息
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
int update(BmProDepart tbProDepart);
|
||||
|
||||
/**
|
||||
* 删除项目部信息
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
int deleteById(BmProDepart tbProDepart);
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.bonus.material.basic.mapper;
|
||||
|
||||
import com.bonus.material.basic.domain.BmProDepart;
|
||||
import com.bonus.material.basic.domain.BmTeam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName BmProDepartMapper
|
||||
* @Author ma_sh
|
||||
* @create 2025/5/12 10:14
|
||||
*/
|
||||
public interface BmTeamMapper {
|
||||
|
||||
/**
|
||||
* 查询班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
List<BmTeam> queryByPage(BmTeam tbTeam);
|
||||
|
||||
/**
|
||||
* 根据名称查询班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
BmTeam selectByName(BmTeam tbTeam);
|
||||
|
||||
/**
|
||||
* 新增班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
int insert(BmTeam tbTeam);
|
||||
|
||||
/**
|
||||
* 修改班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
int update(BmTeam tbTeam);
|
||||
|
||||
/**
|
||||
* 删除班组数据
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
int deleteById(BmTeam tbTeam);
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.bonus.material.basic.service;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.basic.domain.BmProDepart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目部管理服务接口
|
||||
* @Author ma_sh
|
||||
* @create 2025/5/12 10:12
|
||||
*/
|
||||
public interface BmProDepartService {
|
||||
|
||||
/**
|
||||
* 查询项目部列表信息
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
List<BmProDepart> queryByPage(BmProDepart tbProDepart);
|
||||
|
||||
/**
|
||||
* 新增项目部
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
AjaxResult insert(BmProDepart tbProDepart);
|
||||
|
||||
/**
|
||||
* 编辑项目部
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
AjaxResult update(BmProDepart tbProDepart);
|
||||
|
||||
/**
|
||||
* 删除项目部
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
AjaxResult deleteById(BmProDepart tbProDepart);
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.bonus.material.basic.service;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.basic.domain.BmTeam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName BmTeamService
|
||||
* @Author ma_sh
|
||||
* @create 2025/5/12 13:02
|
||||
*/
|
||||
public interface BmTeamService {
|
||||
/**
|
||||
* 查询班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
List<BmTeam> queryByPage(BmTeam tbTeam);
|
||||
|
||||
/**
|
||||
* 新增班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
AjaxResult insert(BmTeam tbTeam);
|
||||
|
||||
/**
|
||||
* 编辑班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
AjaxResult edit(BmTeam tbTeam);
|
||||
|
||||
/**
|
||||
* 删除班组数据
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
AjaxResult deleteById(BmTeam tbTeam);
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
package com.bonus.material.basic.service.impl;
|
||||
|
||||
import cn.hutool.core.util.PhoneUtil;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.bonus.common.biz.enums.HttpCodeEnum;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.basic.domain.BmProDepart;
|
||||
import com.bonus.material.basic.domain.BmTeam;
|
||||
import com.bonus.material.basic.mapper.BmProDepartMapper;
|
||||
import com.bonus.material.basic.mapper.BmTeamMapper;
|
||||
import com.bonus.material.basic.service.BmProDepartService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 项目部管理实现层
|
||||
* @Author ma_sh
|
||||
* @create 2025/5/12 10:12
|
||||
*/
|
||||
@Service
|
||||
public class BmProDepartServiceImpl implements BmProDepartService {
|
||||
|
||||
@Resource
|
||||
private BmProDepartMapper bmProDepartMapper;
|
||||
|
||||
@Resource
|
||||
private BmTeamMapper bmTeamMapper;
|
||||
|
||||
/**
|
||||
* 查询项目部列表信息
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<BmProDepart> queryByPage(BmProDepart tbProDepart) {
|
||||
return bmProDepartMapper.queryByPage(tbProDepart);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增项目部
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult insert(BmProDepart tbProDepart) {
|
||||
if (tbProDepart == null) {
|
||||
return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg());
|
||||
}
|
||||
//名称重复性校验
|
||||
BmProDepart depart = bmProDepartMapper.selectByName(tbProDepart);
|
||||
if (depart != null) {
|
||||
return AjaxResult.error(HttpCodeEnum.NAME_DUPLICATE.getCode(), HttpCodeEnum.NAME_DUPLICATE.getMsg());
|
||||
}
|
||||
if (getObjectResultBean(tbProDepart)) {
|
||||
return AjaxResult.error(HttpCodeEnum.INVALID_PHONE_NUMBER_FORMAT.getCode(), HttpCodeEnum.INVALID_PHONE_NUMBER_FORMAT.getMsg());
|
||||
}
|
||||
tbProDepart.setCreateUser(SecurityUtils.getUserId());
|
||||
int result = bmProDepartMapper.insert(tbProDepart);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.UPDATE_TO_DATABASE.getCode(), HttpCodeEnum.UPDATE_TO_DATABASE.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑项目部
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult update(BmProDepart tbProDepart) {
|
||||
if (tbProDepart == null || tbProDepart.getId() == null) {
|
||||
return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg());
|
||||
}
|
||||
//名称重复性校验
|
||||
BmProDepart depart = bmProDepartMapper.selectByName(tbProDepart);
|
||||
if (depart != null) {
|
||||
if (!Objects.equals(depart.getId(), tbProDepart.getId())) {
|
||||
return AjaxResult.error(HttpCodeEnum.NAME_DUPLICATE.getCode(), HttpCodeEnum.NAME_DUPLICATE.getMsg());
|
||||
}
|
||||
}
|
||||
if (getObjectResultBean(tbProDepart)) {
|
||||
return AjaxResult.error(HttpCodeEnum.INVALID_PHONE_NUMBER_FORMAT.getCode(), HttpCodeEnum.INVALID_PHONE_NUMBER_FORMAT.getMsg());
|
||||
}
|
||||
tbProDepart.setUpdateUser(SecurityUtils.getUserId());
|
||||
int result = bmProDepartMapper.update(tbProDepart);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.UPDATE_TO_DATABASE.getCode(), HttpCodeEnum.UPDATE_TO_DATABASE.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除项目部
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult deleteById(BmProDepart tbProDepart) {
|
||||
if (tbProDepart == null || tbProDepart.getId() == null) {
|
||||
return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg());
|
||||
}
|
||||
// 先根据项目部id查询,该项目部是否被班组关联,若被关联,则无法删除
|
||||
BmTeam bmTeam = new BmTeam();
|
||||
bmTeam.setDepartId(tbProDepart.getId());
|
||||
List<BmTeam> list = bmTeamMapper.queryByPage(bmTeam);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
return AjaxResult.error(HttpCodeEnum.DEPART_IS_RELATED_TEAM.getCode(), HttpCodeEnum.DEPART_IS_RELATED_TEAM.getMsg());
|
||||
}
|
||||
// 进行删除操作
|
||||
int result = bmProDepartMapper.deleteById(tbProDepart);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.UPDATE_TO_DATABASE.getCode(), HttpCodeEnum.UPDATE_TO_DATABASE.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验手机号格式
|
||||
* @param tbProDepart
|
||||
* @return
|
||||
*/
|
||||
private boolean getObjectResultBean(BmProDepart tbProDepart) {
|
||||
if (StringUtils.isNotBlank(tbProDepart.getHeadUserPhone())) {
|
||||
if (!PhoneUtil.isMobile(tbProDepart.getHeadUserPhone())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
package com.bonus.material.basic.service.impl;
|
||||
|
||||
import cn.hutool.core.util.PhoneUtil;
|
||||
import com.bonus.common.biz.enums.HttpCodeEnum;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.basic.domain.BmTeam;
|
||||
import com.bonus.material.basic.mapper.BmTeamMapper;
|
||||
import com.bonus.material.basic.service.BmTeamService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 班组管理接口实现类
|
||||
* @Author ma_sh
|
||||
* @create 2025/5/12 13:03
|
||||
*/
|
||||
@Service
|
||||
public class BmTeamServiceImpl implements BmTeamService {
|
||||
|
||||
@Resource
|
||||
private BmTeamMapper bmTeamMapper;
|
||||
|
||||
/**
|
||||
* 查询班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<BmTeam> queryByPage(BmTeam tbTeam) {
|
||||
return bmTeamMapper.queryByPage(tbTeam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult insert(BmTeam tbTeam) {
|
||||
if (tbTeam == null) {
|
||||
return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg());
|
||||
}
|
||||
//名称重复性校验
|
||||
BmTeam bmTeam = bmTeamMapper.selectByName(tbTeam);
|
||||
if (bmTeam != null) {
|
||||
return AjaxResult.error(HttpCodeEnum.NAME_DUPLICATE.getCode(), HttpCodeEnum.NAME_DUPLICATE.getMsg());
|
||||
}
|
||||
if (getObjectResultBean(tbTeam)) {
|
||||
return AjaxResult.error(HttpCodeEnum.INVALID_PHONE_NUMBER_FORMAT.getCode(), HttpCodeEnum.INVALID_PHONE_NUMBER_FORMAT.getMsg());
|
||||
}
|
||||
tbTeam.setCreateUser(SecurityUtils.getUserId());
|
||||
int result = bmTeamMapper.insert(tbTeam);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.UPDATE_TO_DATABASE.getCode(), HttpCodeEnum.UPDATE_TO_DATABASE.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑班组信息
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult edit(BmTeam tbTeam) {
|
||||
if (tbTeam == null || tbTeam.getId() == null) {
|
||||
return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg());
|
||||
}
|
||||
//名称重复性校验
|
||||
BmTeam bmTeam = bmTeamMapper.selectByName(tbTeam);
|
||||
if (bmTeam != null) {
|
||||
if (!Objects.equals(bmTeam.getId(), tbTeam.getId())) {
|
||||
return AjaxResult.error(HttpCodeEnum.NAME_DUPLICATE.getCode(), HttpCodeEnum.NAME_DUPLICATE.getMsg());
|
||||
}
|
||||
}
|
||||
if (getObjectResultBean(tbTeam)) {
|
||||
return AjaxResult.error(HttpCodeEnum.INVALID_PHONE_NUMBER_FORMAT.getCode(), HttpCodeEnum.INVALID_PHONE_NUMBER_FORMAT.getMsg());
|
||||
}
|
||||
tbTeam.setUpdateUser(SecurityUtils.getUserId());
|
||||
int result = bmTeamMapper.update(tbTeam);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.UPDATE_TO_DATABASE.getCode(), HttpCodeEnum.UPDATE_TO_DATABASE.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除班组数据
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult deleteById(BmTeam tbTeam) {
|
||||
if (tbTeam == null || tbTeam.getId() == null) {
|
||||
return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg());
|
||||
}
|
||||
int result = bmTeamMapper.deleteById(tbTeam);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.UPDATE_TO_DATABASE.getCode(), HttpCodeEnum.UPDATE_TO_DATABASE.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号校验方法抽取
|
||||
* @param tbTeam
|
||||
* @return
|
||||
*/
|
||||
private boolean getObjectResultBean(BmTeam tbTeam) {
|
||||
if (StringUtils.isNotBlank(tbTeam.getRelPhone())) {
|
||||
if (!PhoneUtil.isMobile(tbTeam.getRelPhone())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.material.basic.mapper.BmProDepartMapper">
|
||||
|
||||
<insert id="insert">
|
||||
INSERT INTO bm_pro_depart
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="departName != null">depart_name,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
<if test="headUser != null">head_user,</if>
|
||||
<if test="headUserPhone != null">head_user_phone,</if>
|
||||
create_time,
|
||||
<if test="createUser != null">create_by,</if>
|
||||
del_flag
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="departName != null">#{departName},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
<if test="headUser != null">#{headUser},</if>
|
||||
<if test="headUserPhone != null">#{headUserPhone},</if>
|
||||
NOW(),
|
||||
<if test="createUser != null">#{createUser},</if>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
update bm_pro_depart
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="departName != null">depart_name = #{departName},</if>
|
||||
<if test="deptId != null">dept_id = #{deptId},</if>
|
||||
<if test="headUser != null">head_user = #{headUser},</if>
|
||||
<if test="headUserPhone != null">head_user_phone = #{headUserPhone},</if>
|
||||
update_time = NOW(),
|
||||
<if test="updateUser != null">update_by = #{updateUser},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
update bm_pro_depart
|
||||
set del_flag = '2'
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="queryByPage" resultType="com.bonus.material.basic.domain.BmProDepart">
|
||||
select tpd.id as id,
|
||||
tpd.depart_name as departName,
|
||||
tpd.dept_id as deptId,
|
||||
sd.dept_name as deptName,
|
||||
tpd.head_user as headUser,
|
||||
tpd.head_user_phone as headUserPhone,
|
||||
tpd.create_time as createTime,
|
||||
tpd.create_by as createUser,
|
||||
tpd.update_time as updateTime,
|
||||
tpd.update_by as updateUser,
|
||||
tpd.del_flag as delFlag
|
||||
from bm_pro_depart tpd
|
||||
left join sys_dept sd on sd.dept_id = tpd.dept_id
|
||||
where tpd.del_flag = '0'
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (
|
||||
tpd.depart_name like concat('%', #{keyWord}, '%') or
|
||||
sd.dept_name like concat('%', #{keyWord}, '%') or
|
||||
tpd.head_user like concat('%', #{keyWord}, '%') or
|
||||
tpd.head_user_phone like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
ORDER BY tpd.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectByName" resultType="com.bonus.material.basic.domain.BmProDepart">
|
||||
select id as id, depart_name as departName, head_user as headUser,
|
||||
head_user_phone as headUserPhone, create_time as createTime, create_by as createUser,
|
||||
update_time as updateTime, update_by as updateUser, del_flag as delFlag
|
||||
from bm_pro_depart
|
||||
where del_flag = '0'
|
||||
<if test="departName != null and departName != ''">
|
||||
and depart_name = #{departName}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.material.basic.mapper.BmTeamMapper">
|
||||
<insert id="insert">
|
||||
INSERT INTO bm_team
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="teamName != null">team_name,</if>
|
||||
<if test="departId != null">depart_id,</if>
|
||||
<if test="relName != null">rel_name,</if>
|
||||
<if test="relPhone != null">rel_phone,</if>
|
||||
create_time,
|
||||
<if test="createUser != null">create_by,</if>
|
||||
del_flag
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="teamName != null">#{teamName},</if>
|
||||
<if test="departId != null">#{departId},</if>
|
||||
<if test="relName != null">#{relName},</if>
|
||||
<if test="relPhone != null">#{relPhone},</if>
|
||||
NOW(),
|
||||
<if test="createUser != null">#{createUser},</if>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
UPDATE bm_team
|
||||
<set>
|
||||
<if test="teamName != null">team_name = #{teamName},</if>
|
||||
<if test="departId != null">depart_id = #{departId},</if>
|
||||
<if test="relName != null">rel_name = #{relName},</if>
|
||||
<if test="relPhone != null">rel_phone = #{relPhone},</if>
|
||||
<if test="updateUser != null">update_by = #{updateUser},</if>
|
||||
update_time = NOW()
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
update bm_team
|
||||
set del_flag = '2'
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="queryByPage" resultType="com.bonus.material.basic.domain.BmTeam">
|
||||
select t.id as id,
|
||||
t.team_name as teamName,
|
||||
t.depart_id as departId,
|
||||
sd.depart_name as departName,
|
||||
t.rel_name as relName,
|
||||
t.rel_phone as relPhone,
|
||||
t.create_time as createTime,
|
||||
t.create_by as createUser,
|
||||
t.update_time as updateTime,
|
||||
t.update_by as updateUser,
|
||||
t.del_flag as delFlag
|
||||
from bm_team t
|
||||
left join bm_pro_depart sd on t.depart_id = sd.id
|
||||
where t.del_flag = 0 and sd.del_flag = 0
|
||||
<if test="departId != null ">
|
||||
and t.depart_id = #{departId}
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (
|
||||
t.team_name like concat('%', #{keyWord}, '%') or
|
||||
sd.depart_name like concat('%', #{keyWord}, '%') or
|
||||
t.rel_name like concat('%', #{keyWord}, '%') or
|
||||
t.rel_phone like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
ORDER BY t.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectByName" resultType="com.bonus.material.basic.domain.BmTeam">
|
||||
select id as id, team_name as teamName, rel_name as relName,
|
||||
rel_phone as relPhone, create_time as createTime, create_by as createUser,
|
||||
update_time as updateTime, update_by as updateUser, del_flag as delFlag
|
||||
from bm_team
|
||||
where del_flag = 0
|
||||
<if test="teamName != null and teamName != ''">
|
||||
and team_name = #{teamName}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue