New file |
| | |
| | | package com.moral.api.controller; |
| | | |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import org.apache.ibatis.annotations.Update; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | 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 java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.ResponsibilityUnit; |
| | | import com.moral.api.service.ResponsibilityUnitService; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.WebUtils; |
| | | |
| | | @Api(tags = "责任单位") |
| | | @RestController |
| | | @RequestMapping("unit") |
| | | public class ResponsibilityUnitController { |
| | | |
| | | |
| | | @Autowired |
| | | private ResponsibilityUnitService responsibilityUnitService; |
| | | |
| | | |
| | | /** |
| | | * 新增表单 |
| | | * @param responsibilityUnit |
| | | * @return |
| | | */ |
| | | @PostMapping("insert") |
| | | public ResultMessage insert(@RequestBody ResponsibilityUnit responsibilityUnit){ |
| | | |
| | | Integer insert = responsibilityUnitService.insert(responsibilityUnit); |
| | | if (insert<0){ |
| | | return ResultMessage.fail(ResponseCodeEnum.ROLE_IS_EXIST.getCode(),ResponseCodeEnum.ROLE_IS_EXIST.getMsg()); |
| | | } |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 查询表单 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @GetMapping("selectUint") |
| | | public ResultMessage selectUint(HttpServletRequest request){ |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | |
| | | Map<String, Object> map = responsibilityUnitService.selectUnit(parameters); |
| | | |
| | | return ResultMessage.ok(map); |
| | | } |
| | | |
| | | /** |
| | | * 修改表单 |
| | | * @param responsibilityUnit |
| | | * @return |
| | | */ |
| | | @PostMapping("update") |
| | | public ResultMessage updateUnit(@RequestBody ResponsibilityUnit responsibilityUnit){ |
| | | Integer integer = responsibilityUnitService.updateUnit(responsibilityUnit); |
| | | if (integer<0){ |
| | | return ResultMessage.fail(ResponseCodeEnum.ROLE_IS_EXIST.getCode(),ResponseCodeEnum.ROLE_IS_EXIST.getMsg()); |
| | | } |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 改变状态 |
| | | * @param unitId |
| | | * @return |
| | | */ |
| | | @GetMapping("state") |
| | | public ResultMessage state(Integer unitId){ |
| | | if (ObjectUtils.isEmpty(unitId)){ |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | responsibilityUnitService.updateState(unitId); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 是否作废 |
| | | * @param unitId |
| | | * @param code |
| | | * @return |
| | | */ |
| | | @GetMapping("invalid") |
| | | public ResultMessage invalid(Integer unitId,String code){ |
| | | if (ObjectUtils.isEmpty(unitId)){ |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | responsibilityUnitService.updateInvalid(unitId,code); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 是否删除 |
| | | * @param unitId |
| | | * @return |
| | | */ |
| | | @GetMapping("delete") |
| | | public ResultMessage delete(Integer unitId){ |
| | | responsibilityUnitService.removeById(unitId); |
| | | return ResultMessage.ok(); |
| | | } |
| | | } |