Organization CURD
This commit is contained in:
parent
f2b2de0aa2
commit
be55317212
|
@ -0,0 +1,28 @@
|
|||
package io.metersphere.controller;
|
||||
|
||||
import io.metersphere.base.domain.Organization;
|
||||
import io.metersphere.service.OrganizationService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping("organization")
|
||||
@RestController
|
||||
public class OrganizationController {
|
||||
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
|
||||
@PostMapping("/add")
|
||||
public Organization addOrganization(@RequestBody Organization organization) { return organizationService.addOrganization(organization); }
|
||||
|
||||
@GetMapping("/list")
|
||||
public List<Organization> getOrganizationList() { return organizationService.getOrganizationList(); }
|
||||
|
||||
@GetMapping("/delete/{organizationId}")
|
||||
public void deleteOrganization(@PathVariable(value = "organizationId") String organizationId) { organizationService.deleteOrganization(organizationId); }
|
||||
|
||||
@PostMapping("/update")
|
||||
public void updateOrganization(@RequestBody Organization organization) { organizationService.updateOrganization(organization); }
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package io.metersphere.service;
|
||||
|
||||
import io.metersphere.base.domain.Organization;
|
||||
import io.metersphere.base.mapper.OrganizationMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class OrganizationService {
|
||||
|
||||
@Resource
|
||||
private OrganizationMapper organizationMapper;
|
||||
|
||||
public Organization addOrganization(Organization organization) {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
organization.setId(UUID.randomUUID().toString());
|
||||
organization.setCreateTime(currentTimeMillis);
|
||||
organization.setUpdateTime(currentTimeMillis);
|
||||
organizationMapper.insertSelective(organization);
|
||||
return organization;
|
||||
}
|
||||
|
||||
public List<Organization> getOrganizationList() {
|
||||
return organizationMapper.selectByExample(null);
|
||||
}
|
||||
|
||||
public void deleteOrganization(String organizationId) {
|
||||
organizationMapper.deleteByPrimaryKey(organizationId);
|
||||
}
|
||||
|
||||
public void updateOrganization(Organization organization) {
|
||||
organization.setUpdateTime(System.currentTimeMillis());
|
||||
organizationMapper.updateByPrimaryKeySelective(organization);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue