GroupCompanyController.java 3.3 KB
package com.tianbo.warehouse.controller;

import com.github.pagehelper.PageInfo;
import com.tianbo.warehouse.annotation.LogAnnotation;
import com.tianbo.warehouse.controller.response.ResultJson;
import com.tianbo.warehouse.model.Department;
import com.tianbo.warehouse.model.Group_company;
import com.tianbo.warehouse.service.DepartmentService;
import com.tianbo.warehouse.service.GroupCompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

@RestController
@RequestMapping("/group")
public class GroupCompanyController {

    @Autowired
    GroupCompanyService groupCompanyService;

    @GetMapping("/list")
    public PageInfo<Group_company> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")
                                             int pageNum,
                                        @RequestParam(value = "pageSize",required = false,defaultValue = "5")
                                             int pageSize,
                                        @RequestParam(value = "groupName") String groupName){
        return groupCompanyService.findAll(pageNum,pageSize, groupName);

    }

    @LogAnnotation(moduleName = "集团管理",operate = "集团添加")
    @PostMapping("/add")
    public ResultJson add(@RequestBody Group_company group_company){

        int i =groupCompanyService.insertSelective(group_company);

        ResultJson resultJson = new ResultJson();
        if (1==i){
            resultJson = new ResultJson("200","添加成功");
        }else {
            resultJson = new ResultJson("500","insert faild");
        }
        return resultJson;
    }

    @LogAnnotation(moduleName = "集团管理",operate = "集团修改")
    @PutMapping("/edit")
    @ResponseBody
    public ResultJson edit(@RequestBody @Valid Group_company group_company){

        int i =groupCompanyService.updateByPrimaryKeySelective(group_company);

        ResultJson resultJson = new ResultJson();
        if (1==i){
            resultJson = new ResultJson("200","修改成功");
        }else {
            resultJson = new ResultJson("500","insert faild");
        }
        return resultJson;
    }

    @LogAnnotation(moduleName = "集团管理",operate = "集团删除")
    @DeleteMapping("/del")
    public ResultJson reomve(@RequestBody Group_company group_company, HttpServletRequest request, HttpServletResponse response){

        int i =groupCompanyService.deleteByPrimaryKey(group_company.getGroupId());

        ResultJson resultJson = new ResultJson();
        if (1==i){
            resultJson = new ResultJson("200","删除成功");
        }else {
            resultJson = new ResultJson("500","insert faild");
        }
        return resultJson;
    }

    @LogAnnotation(moduleName = "集团管理",operate = "集团批量删除")
    @GetMapping("/batchremove")
    public ResultJson reomve(String ids, HttpServletRequest request, HttpServletResponse response){

        ResultJson resultJson = new ResultJson();

        if (groupCompanyService.deleteByPrimaryKey(ids)>0){
            resultJson = new ResultJson("200","删除成功");
        }else {
            resultJson = new ResultJson("500","insert faild");
        }
        return resultJson;
    }

}