IBIZSample0014Resource.java 11.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
package cn.ibizlab.demoapi.rest;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.ServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import cn.ibizlab.demoapi.dto.*;
import cn.ibizlab.demoapi.mapping.*;
import cn.ibizlab.core.sample.domain.IBIZSample0014;
import cn.ibizlab.core.sample.service.IIBIZSample0014Service;
import cn.ibizlab.core.sample.filter.IBIZSample0014SearchContext;
import cn.ibizlab.util.annotation.VersionCheck;

@Slf4j
@Api(tags = {"员工" })
@RestController("DemoAPI-ibizsample0014")
@RequestMapping("")
public class IBIZSample0014Resource {

    @Autowired
    public IIBIZSample0014Service ibizsample0014Service;

    @Autowired
    @Lazy
    public IBIZSample0014Mapping ibizsample0014Mapping;

    @PreAuthorize("hasPermission(this.ibizsample0014Mapping.toDomain(#ibizsample0014dto),'DemoSys-IBIZSample0014-Create')")
    @ApiOperation(value = "新建员工", tags = {"员工" },  notes = "新建员工")
	@RequestMapping(method = RequestMethod.POST, value = "/ibizsample0014s")
    public ResponseEntity<IBIZSample0014DTO> create(@Validated @RequestBody IBIZSample0014DTO ibizsample0014dto) {
        IBIZSample0014 domain = ibizsample0014Mapping.toDomain(ibizsample0014dto);
		ibizsample0014Service.create(domain);
        IBIZSample0014DTO dto = ibizsample0014Mapping.toDto(domain);
		return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.ibizsample0014Mapping.toDomain(#ibizsample0014dtos),'DemoSys-IBIZSample0014-Create')")
    @ApiOperation(value = "批量新建员工", tags = {"员工" },  notes = "批量新建员工")
	@RequestMapping(method = RequestMethod.POST, value = "/ibizsample0014s/batch")
    public ResponseEntity<Boolean> createBatch(@RequestBody List<IBIZSample0014DTO> ibizsample0014dtos) {
        ibizsample0014Service.createBatch(ibizsample0014Mapping.toDomain(ibizsample0014dtos));
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @VersionCheck(entity = "ibizsample0014" , versionfield = "updatedate")
    @PreAuthorize("hasPermission(this.ibizsample0014Service.get(#ibizsample0014_id),'DemoSys-IBIZSample0014-Update')")
    @ApiOperation(value = "更新员工", tags = {"员工" },  notes = "更新员工")
	@RequestMapping(method = RequestMethod.PUT, value = "/ibizsample0014s/{ibizsample0014_id}")
    public ResponseEntity<IBIZSample0014DTO> update(@PathVariable("ibizsample0014_id") String ibizsample0014_id, @RequestBody IBIZSample0014DTO ibizsample0014dto) {
		IBIZSample0014 domain  = ibizsample0014Mapping.toDomain(ibizsample0014dto);
        domain .setIbizsample0014id(ibizsample0014_id);
		ibizsample0014Service.update(domain );
		IBIZSample0014DTO dto = ibizsample0014Mapping.toDto(domain );
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @PreAuthorize("hasPermission(this.ibizsample0014Service.getIbizsample0014ByEntities(this.ibizsample0014Mapping.toDomain(#ibizsample0014dtos)),'DemoSys-IBIZSample0014-Update')")
    @ApiOperation(value = "批量更新员工", tags = {"员工" },  notes = "批量更新员工")
	@RequestMapping(method = RequestMethod.PUT, value = "/ibizsample0014s/batch")
    public ResponseEntity<Boolean> updateBatch(@RequestBody List<IBIZSample0014DTO> ibizsample0014dtos) {
        ibizsample0014Service.updateBatch(ibizsample0014Mapping.toDomain(ibizsample0014dtos));
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasPermission(this.ibizsample0014Service.get(#ibizsample0014_id),'DemoSys-IBIZSample0014-Remove')")
    @ApiOperation(value = "删除员工", tags = {"员工" },  notes = "删除员工")
	@RequestMapping(method = RequestMethod.DELETE, value = "/ibizsample0014s/{ibizsample0014_id}")
    public ResponseEntity<Boolean> remove(@PathVariable("ibizsample0014_id") String ibizsample0014_id) {
         return ResponseEntity.status(HttpStatus.OK).body(ibizsample0014Service.remove(ibizsample0014_id));
    }

    @PreAuthorize("hasPermission(this.ibizsample0014Service.getIbizsample0014ByIds(#ids),'DemoSys-IBIZSample0014-Remove')")
    @ApiOperation(value = "批量删除员工", tags = {"员工" },  notes = "批量删除员工")
	@RequestMapping(method = RequestMethod.DELETE, value = "/ibizsample0014s/batch")
    public ResponseEntity<Boolean> removeBatch(@RequestBody List<String> ids) {
        ibizsample0014Service.removeBatch(ids);
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PostAuthorize("hasPermission(this.ibizsample0014Mapping.toDomain(returnObject.body),'DemoSys-IBIZSample0014-Get')")
    @ApiOperation(value = "获取员工", tags = {"员工" },  notes = "获取员工")
	@RequestMapping(method = RequestMethod.GET, value = "/ibizsample0014s/{ibizsample0014_id}")
    public ResponseEntity<IBIZSample0014DTO> get(@PathVariable("ibizsample0014_id") String ibizsample0014_id) {
        IBIZSample0014 domain = ibizsample0014Service.get(ibizsample0014_id);
        IBIZSample0014DTO dto = ibizsample0014Mapping.toDto(domain);
        return ResponseEntity.status(HttpStatus.OK).body(dto);
    }

    @ApiOperation(value = "获取员工草稿", tags = {"员工" },  notes = "获取员工草稿")
	@RequestMapping(method = RequestMethod.GET, value = "/ibizsample0014s/getdraft")
    public ResponseEntity<IBIZSample0014DTO> getDraft() {
        return ResponseEntity.status(HttpStatus.OK).body(ibizsample0014Mapping.toDto(ibizsample0014Service.getDraft(new IBIZSample0014())));
    }

    @ApiOperation(value = "检查员工", tags = {"员工" },  notes = "检查员工")
	@RequestMapping(method = RequestMethod.POST, value = "/ibizsample0014s/checkkey")
    public ResponseEntity<Boolean> checkKey(@RequestBody IBIZSample0014DTO ibizsample0014dto) {
        return  ResponseEntity.status(HttpStatus.OK).body(ibizsample0014Service.checkKey(ibizsample0014Mapping.toDomain(ibizsample0014dto)));
    }

    @PreAuthorize("hasPermission(this.ibizsample0014Mapping.toDomain(#ibizsample0014dto),'DemoSys-IBIZSample0014-Save')")
    @ApiOperation(value = "保存员工", tags = {"员工" },  notes = "保存员工")
	@RequestMapping(method = RequestMethod.POST, value = "/ibizsample0014s/save")
    public ResponseEntity<Boolean> save(@RequestBody IBIZSample0014DTO ibizsample0014dto) {
        return ResponseEntity.status(HttpStatus.OK).body(ibizsample0014Service.save(ibizsample0014Mapping.toDomain(ibizsample0014dto)));
    }

    @PreAuthorize("hasPermission(this.ibizsample0014Mapping.toDomain(#ibizsample0014dtos),'DemoSys-IBIZSample0014-Save')")
    @ApiOperation(value = "批量保存员工", tags = {"员工" },  notes = "批量保存员工")
	@RequestMapping(method = RequestMethod.POST, value = "/ibizsample0014s/savebatch")
    public ResponseEntity<Boolean> saveBatch(@RequestBody List<IBIZSample0014DTO> ibizsample0014dtos) {
        ibizsample0014Service.saveBatch(ibizsample0014Mapping.toDomain(ibizsample0014dtos));
        return  ResponseEntity.status(HttpStatus.OK).body(true);
    }

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','DemoSys-IBIZSample0014-searchCurIBIZSample0014-all') and hasPermission(#context,'DemoSys-IBIZSample0014-Get')")
	@ApiOperation(value = "获取CurIBIZSample0014", tags = {"员工" } ,notes = "获取CurIBIZSample0014")
141
    @RequestMapping(method= RequestMethod.GET , value="/ibizsample0014s/fetchcuribizsample0014")
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
	public ResponseEntity<List<IBIZSample0014DTO>> fetchCurIBIZSample0014(IBIZSample0014SearchContext context) {
        Page<IBIZSample0014> domains = ibizsample0014Service.searchCurIBIZSample0014(context) ;
        List<IBIZSample0014DTO> list = ibizsample0014Mapping.toDto(domains.getContent());
        return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','DemoSys-IBIZSample0014-searchCurIBIZSample0014-all') and hasPermission(#context,'DemoSys-IBIZSample0014-Get')")
	@ApiOperation(value = "查询CurIBIZSample0014", tags = {"员工" } ,notes = "查询CurIBIZSample0014")
    @RequestMapping(method= RequestMethod.POST , value="/ibizsample0014s/searchcuribizsample0014")
	public ResponseEntity<Page<IBIZSample0014DTO>> searchCurIBIZSample0014(@RequestBody IBIZSample0014SearchContext context) {
        Page<IBIZSample0014> domains = ibizsample0014Service.searchCurIBIZSample0014(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(ibizsample0014Mapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','DemoSys-IBIZSample0014-searchDefault-all') and hasPermission(#context,'DemoSys-IBIZSample0014-Get')")
	@ApiOperation(value = "获取DEFAULT", tags = {"员工" } ,notes = "获取DEFAULT")
163
    @RequestMapping(method= RequestMethod.GET , value="/ibizsample0014s/fetchdefault")
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
	public ResponseEntity<List<IBIZSample0014DTO>> fetchDefault(IBIZSample0014SearchContext context) {
        Page<IBIZSample0014> domains = ibizsample0014Service.searchDefault(context) ;
        List<IBIZSample0014DTO> list = ibizsample0014Mapping.toDto(domains.getContent());
        return ResponseEntity.status(HttpStatus.OK)
                .header("x-page", String.valueOf(context.getPageable().getPageNumber()))
                .header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
                .header("x-total", String.valueOf(domains.getTotalElements()))
                .body(list);
	}

    @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','DemoSys-IBIZSample0014-searchDefault-all') and hasPermission(#context,'DemoSys-IBIZSample0014-Get')")
	@ApiOperation(value = "查询DEFAULT", tags = {"员工" } ,notes = "查询DEFAULT")
    @RequestMapping(method= RequestMethod.POST , value="/ibizsample0014s/searchdefault")
	public ResponseEntity<Page<IBIZSample0014DTO>> searchDefault(@RequestBody IBIZSample0014SearchContext context) {
        Page<IBIZSample0014> domains = ibizsample0014Service.searchDefault(context) ;
	    return ResponseEntity.status(HttpStatus.OK)
                .body(new PageImpl(ibizsample0014Mapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
	}


}