Browse Source

任务来源:机场

任务描述:部门管理功能开发
develop
wubin 1 year ago
parent
commit
a7d9fa8af2
6 changed files with 220 additions and 0 deletions
  1. +24
    -0
      tuoheng-system/src/main/java/com/tuoheng/system/controller/DemoController.java
  2. +74
    -0
      tuoheng-system/src/main/java/com/tuoheng/system/controller/dept/DeptController.java
  3. +14
    -0
      tuoheng-system/src/main/java/com/tuoheng/system/mapper/DeptMapper.java
  4. +43
    -0
      tuoheng-system/src/main/java/com/tuoheng/system/pojo/entity/Dept.java
  5. +21
    -0
      tuoheng-system/src/main/java/com/tuoheng/system/service/dept/IDeptService.java
  6. +44
    -0
      tuoheng-system/src/main/java/com/tuoheng/system/service/dept/impl/DeptServiceImpl.java

+ 24
- 0
tuoheng-system/src/main/java/com/tuoheng/system/controller/DemoController.java View File

@@ -0,0 +1,24 @@
package com.tuoheng.system.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* @Author: 吴彬
* @CreateTime: 2023-06-13 19:09
* @Description: Demo
* @Version: 1.0
*/
@RestController
@RequestMapping("/demo")
public class DemoController {

/**
* Demo
*/
@GetMapping("/test")
public String health() {
return "ok";
}
}

+ 74
- 0
tuoheng-system/src/main/java/com/tuoheng/system/controller/dept/DeptController.java View File

@@ -0,0 +1,74 @@
package com.tuoheng.system.controller.dept;


import com.tuoheng.common.annotation.Log;
import com.tuoheng.common.common.BaseController;
import com.tuoheng.common.enums.LogType;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.system.pojo.entity.Dept;
import com.tuoheng.system.service.dept.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
* @Author: 吴彬
* @CreateTime: 2023-06-13 16:31
* @Description: 部门表 前端控制器
* @Version: 1.0
*/
@RestController
@RequestMapping("/dept")
public class DeptController extends BaseController {

@Autowired
private IDeptService deptService;

/**
* 获取部门列表
*
* @return
*/
@GetMapping("/index")
public JsonResult index() {
return deptService.getDeptList();
}

/**
* 添加部门
*
* @param entity 实体对象
* @return
*/
@PostMapping("/add")
public JsonResult add(@Valid @RequestBody Dept entity) {
//TODO 获取当前登录用户所在的租户
entity.setTenantId(null);
return deptService.edit(entity);
}

/**
* 编辑部门
*
* @param entity 实体对象
* @return
*/
@PutMapping("/edit")
public JsonResult edit(@Valid @RequestBody Dept entity) {
//TODO 获取当前登录用户所在的租户
entity.setTenantId(null);
return deptService.edit(entity);
}

/**
* 删除部门
*
* @param deptId 部门ID
* @return
*/
@DeleteMapping("/delete/{deptId}")
public JsonResult delete(@PathVariable("deptId") Integer deptId) {
return deptService.deleteById(deptId);
}
}

+ 14
- 0
tuoheng-system/src/main/java/com/tuoheng/system/mapper/DeptMapper.java View File

@@ -0,0 +1,14 @@
package com.tuoheng.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.system.pojo.entity.Dept;

/**
* @Author: 吴彬
* @CreateTime: 2023-06-13 16:31
* @Description: 部门表 Mapper 接口
* @Version: 1.0
*/
public interface DeptMapper extends BaseMapper<Dept> {

}

+ 43
- 0
tuoheng-system/src/main/java/com/tuoheng/system/pojo/entity/Dept.java View File

@@ -0,0 +1,43 @@
package com.tuoheng.system.pojo.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.tuoheng.common.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

/**
* @Author: 吴彬
* @CreateTime: 2023-06-13 16:31
* @Description: 部门表
* @Version: 1.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
//TODO 待修改真是部门表
@TableName("sys_dept_copy1")
public class Dept extends BaseEntity {

private static final long serialVersionUID = 1L;

/**
* 部门名称
*/
@Length(max = 50, message = "部门名称长度限制50个字符!")
private String name;


/**
* 上级ID
*/
private Integer pid;

/**
* 关联机场ID
*/
private Integer airportId;


}

+ 21
- 0
tuoheng-system/src/main/java/com/tuoheng/system/service/dept/IDeptService.java View File

@@ -0,0 +1,21 @@
package com.tuoheng.system.service.dept;

import com.tuoheng.common.common.IBaseService;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.system.pojo.entity.Dept;

/**
* @Author: 吴彬
* @CreateTime: 2023-06-13 16:31
* @Description: 部门表 服务类
* @Version: 1.0
*/
public interface IDeptService extends IBaseService<Dept> {

/**
* 获取部门列表
*
* @return
*/
JsonResult getDeptList();
}

+ 44
- 0
tuoheng-system/src/main/java/com/tuoheng/system/service/dept/impl/DeptServiceImpl.java View File

@@ -0,0 +1,44 @@
package com.tuoheng.system.service.dept.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.common.enums.MarkStatusEnum;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.system.mapper.DeptMapper;
import com.tuoheng.system.pojo.entity.Dept;
import com.tuoheng.system.service.dept.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
* @Author: 吴彬
* @CreateTime: 2023-06-13 16:31
* @Description: 部门表 服务实现类
* @Version: 1.0
*/
@Service
public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, Dept> implements IDeptService {

@Autowired
private DeptMapper deptMapper;

/**
* 获取部门列表
*
* @return
*/
@Override
public JsonResult getDeptList() {

// 查询部门数据
List<Dept> deptList = deptMapper.selectList(new LambdaQueryWrapper<Dept>()
//TODO 获取当前登录用户所在的租户
// .eq(Dept::getTenantId,null)
.eq(Dept::getMark, MarkStatusEnum.VALID.getCode())
.orderByDesc(Dept::getCreateTime));
return JsonResult.success(deptList);
}
}

Loading…
Cancel
Save