springboot 业务后台

domain
package me.zhengjie.modules.fzgc.param.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @author lff3042073
* @date 2019-08-01
*/
@Entity
@Data
@Table(name="protype")
public class Protype implements Serializable {

    // ID
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    // 产品型号
    @Column(name = "name")
    private String name;

    // 封装形式
    @OneToOne
    @JoinColumn(name = "encfor_id")
    private  Encfor encfor;

    // 客户名称
    @OneToOne
    @JoinColumn(name = "custom_id")
     private  Custom  custom;

    // 备注
    @Column(name = "remarks")
    private String remarks;

    // 创建人
    @Column(name = "create_by")
    private String createBy;

    // 创建时间
    @CreationTimestamp
    @Column(name = "create_time")
    private Timestamp createTime;

    // 更新人
    @Column(name = "update_by")
    private String updateBy;

    // 更新时间
    @UpdateTimestamp
    @Column(name = "update_time")
    private Timestamp updateTime;

    public void copy(Protype source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
package me.zhengjie.modules.fzgc.param.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.modules.fzgc.set.domain.ModuleGroup;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @author lff3042073
* @date 2019-07-31
*/
@Entity
@Data
@Table(name="encfor")
public class Encfor implements Serializable {

    // ID
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /*// 模块分组关联
    @Column(name = "group_id")
    private Long groupId;
    */

    // 模块分组id
    @OneToOne
    @JoinColumn(name = "group_id")
    private ModuleGroup group;

    // 所属产线
    @Column(name = "line")
    private String line;

    // 封装名称
    @Column(name = "name")
    private String name;

    // 备注
    @Column(name = "remarks")
    private String remarks;

    // 创建人
    @Column(name = "create_by")
    private String createBy;

    // 创建时间
    @CreationTimestamp
    @Column(name = "create_time")
    private Timestamp createTime;

    // 更新人
    @Column(name = "update_by")
    private String updateBy;

    // 更新时间
    @UpdateTimestamp
    @Column(name = "update_time")
    private Timestamp updateTime;

    public void copy(Encfor source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
contron
package me.zhengjie.modules.fzgc.param.rest;

import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.fzgc.param.domain.Protype;
import me.zhengjie.modules.fzgc.param.service.ProtypeService;
import me.zhengjie.modules.fzgc.param.service.dto.ProtypeQueryCriteria;
import me.zhengjie.utils.SecurityUtils;
import org.apache.catalina.security.SecurityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

/**
* @author lff3042073
* @date 2019-08-01
*/
@Api(tags = "Protype管理")
@RestController
@RequestMapping("api")
public class ProtypeController {

    @Autowired
    private ProtypeService protypeService;

    @Log("查询Protype")
    @ApiOperation(value = "查询Protype")
    @GetMapping(value = "/protype")
    @PreAuthorize("hasAnyRole('ADMIN','PROTYPE_ALL','PROTYPE_SELECT')")
    public ResponseEntity getProtypes(ProtypeQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity(protypeService.queryAll(criteria,pageable),HttpStatus.OK);
    }

    @Log("新增Protype")
    @ApiOperation(value = "新增Protype")
    @PostMapping(value = "/protype")
    @PreAuthorize("hasAnyRole('ADMIN','PROTYPE_ALL','PROTYPE_CREATE')")
    public ResponseEntity create(@Validated @RequestBody Protype resources){
        resources.setCreateBy(SecurityUtils.getUsername());
        return new ResponseEntity(protypeService.create(resources),HttpStatus.CREATED);
    }

    @Log("修改Protype")
    @ApiOperation(value = "修改Protype")
    @PutMapping(value = "/protype")
    @PreAuthorize("hasAnyRole('ADMIN','PROTYPE_ALL','PROTYPE_EDIT')")
    public ResponseEntity update(@Validated @RequestBody Protype resources){
        resources.setUpdateBy(SecurityUtils.getUsername());
        protypeService.update(resources);
        return new ResponseEntity(HttpStatus.NO_CONTENT);
    }

    @Log("删除Protype")
    @ApiOperation(value = "删除Protype")
    @DeleteMapping(value = "/protype/{id}")
    @PreAuthorize("hasAnyRole('ADMIN','PROTYPE_ALL','PROTYPE_DELETE')")
    public ResponseEntity delete(@PathVariable Long id){
        protypeService.delete(id);
        return new ResponseEntity(HttpStatus.OK);
    }
}

dto
package me.zhengjie.modules.fzgc.param.service.dto;

import lombok.Data;
import me.zhengjie.modules.fzgc.set.domain.ModuleGroup;

import java.sql.Timestamp;
import java.io.Serializable;

/**

  • @author lff3042073

  • @date 2019-07-31
    */
    @Data
    public class EncforDTO implements Serializable {

    // ID
    private Long id;

    // 模块分组关联
    private Long groupId;

    // 模块分组名称
    private ModuleGroup group;

    // 所属产线
    private String line;

    // 封装名称
    private String name;

    // 备注
    private String remarks;

    // 创建人
    private String createBy;

    // 创建时间
    private Timestamp createTime;

    // 更新人
    private String updateBy;

    // 更新时间
    private Timestamp updateTime;
    }

package me.zhengjie.modules.fzgc.param.service.dto;

import lombok.Data;
import java.sql.Timestamp;
import me.zhengjie.annotation.Query;

/**
* @author lff3042073
* @date 2019-08-01
*/
@Data
public class ProtypeQueryCriteria{

    // 模糊
    @Query(type = Query.Type.INNER_LIKE)
    private String name;
	对象关联
    @Query(propName = "id", type = Query.Type.EQUAL, joinName = "encfor")
    private Long encforId;

    @Query(propName = "id", type = Query.Type.EQUAL, joinName = "custom")
    private Long customId;

}

你可能感兴趣的:(springboot 业务后台)