| | |
| | | package com.moral.controller; |
| | | |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.moral.common.bean.PageBean; |
| | | import com.moral.common.bean.ResultBean; |
| | | import com.moral.entity.Organization; |
| | | import com.moral.security.auth.JwtAuthenticationToken; |
| | | import com.moral.security.model.UserContext; |
| | | import com.moral.service.OrganizationService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import javax.annotation.Resource; |
| | | |
| | | @RestController |
| | | @RequestMapping("organization") |
| | | public class OrganizationController { |
| | | @Resource |
| | | OrganizationService organizationService; |
| | | |
| | | @GetMapping("page-list") |
| | | public PageBean pageList(PageBean pageBean) { |
| | | return organizationService.queryByPageBean(pageBean); |
| | | } |
| | | |
| | | @PostMapping("delete-by-ids") |
| | | public ResultBean deleteByIds(@RequestBody Integer [] ids){ |
| | | public ResultBean deleteByIds(@RequestBody Integer[] ids) { |
| | | organizationService.deleteByIds(ids); |
| | | ResultBean resultBean = new ResultBean(ResultBean.SUCCESS); |
| | | return resultBean; |
| | | } |
| | | |
| | | @PostMapping("add-or-modify") |
| | | public ResultBean addOrModify(@RequestBody Organization organization){ |
| | | public ResultBean addOrModify(@RequestBody Organization organization) { |
| | | organizationService.addOrModify(organization); |
| | | ResultBean resultBean = new ResultBean(ResultBean.SUCCESS); |
| | | return resultBean; |
| | | } |
| | | |
| | | @GetMapping("list/{name}") |
| | | public ResultBean<List<Organization>> getOrganizationsByName(@PathVariable("name") String name) { |
| | | List<Organization> organizations = organizationService.getOrganizationsByName(name); |
| | | return new ResultBean<List<Organization>>(organizations); |
| | | } |
| | | |
| | | @GetMapping("get-my-org") |
| | | public ResultBean<Organization> getMyOrganization(JwtAuthenticationToken token) { |
| | | UserContext userContext = token.getPrincipal(); |
| | | Organization organization = organizationService.getOrganizationById(userContext.getOrganizationId()); |
| | | return new ResultBean<>(organization); |
| | | } |
| | | |
| | | @GetMapping("getforg") |
| | | public ResultBean<Organization> getFatherOrg(Integer cid) { |
| | | Organization organization = organizationService.getFatherOrg(cid); |
| | | return new ResultBean<>(organization); |
| | | } |
| | | |
| | | @GetMapping("organization-list") |
| | | public ResultBean getOrganizationList(String organizationName) { |
| | | ResultBean resultBean = new ResultBean(ResultBean.SUCCESS); |
| | | resultBean.setData(organizationService.getOrganizationList(organizationName)); |
| | | return resultBean; |
| | | } |
| | | } |