@@ -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"; | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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> { | |||
} |
@@ -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; | |||
} |
@@ -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(); | |||
} |
@@ -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); | |||
} | |||
} |