diff --git a/system/src/main/java/com/canvas/web/modules/device/domain/Device.java b/system/src/main/java/com/canvas/web/modules/device/domain/Device.java new file mode 100644 index 0000000..a79bea3 --- /dev/null +++ b/system/src/main/java/com/canvas/web/modules/device/domain/Device.java @@ -0,0 +1,88 @@ +package com.canvas.web.modules.device.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.UpdateTimestamp; + +import javax.persistence.*; +import java.io.Serializable; +import java.sql.Timestamp; + +@Getter +@Setter +@Entity +@Table(name = "device") +public class Device implements Serializable { + + @Id + @Column(name = "id") + @GeneratedValue(generator = "idGenerator") + @GenericGenerator(name = "idGenerator", strategy = "uuid") + private String id ; + + @Column(name = "account") + @ApiModelProperty(value = "设备账号") + public String account; + + @Column(name = "device_name") + @ApiModelProperty(value = "设备名称") + public String deviceName; + + @Column(name = "device_direction") + @ApiModelProperty(value = "设备方向 1.竖屏 2.横屏") + public Integer deviceDirection; + + @Column(name = "orga_id") + @ApiModelProperty(value = "机构id") + public String orgaId; + + @Column(name = "open_setting") + @ApiModelProperty(value = "开机设置 1.每天 2.每周") + public Integer openSetting; + + @Column(name = "open_weekly") + @ApiModelProperty(value = "开机每周 如果设置为每天则为空") + public String openWeekly; + + @Column(name = "open_time") + @ApiModelProperty(value = "开机时间") + public Timestamp openTime; + + @Column(name = "close_setting") + @ApiModelProperty(value = "关机设置 1.每天 2.每周") + public Integer closeSetting; + + @Column(name = "close_weekly") + @ApiModelProperty(value = "关机每周 如果设置为每天则为空") + public String closeWeekly; + + @Column(name = "close_time") + @ApiModelProperty(value = "关机时间") + public Timestamp closeTime; + + @Column(name = "startup_screen") + @ApiModelProperty(value = "启动画面地址") + public String startupScreen; + + @CreationTimestamp + @Column(name = "is_createdate", updatable = false) + @ApiModelProperty(value = "创建时间", hidden = true) + private Timestamp isCreateTime; + + @UpdateTimestamp + @Column(name = "is_updatedate") + @ApiModelProperty(value = "更新时间", hidden = true) + private Timestamp isUpdateTime; + + @Column(name = "is_state") + @ApiModelProperty(value = "停用/禁用", hidden = true) + public Integer isState; + + @Column(name = "is_del") + @ApiModelProperty(value = "停用/禁用", hidden = true) + public Boolean isDel; + +} diff --git a/system/src/main/java/com/canvas/web/modules/device/repository/DeviceRepository.java b/system/src/main/java/com/canvas/web/modules/device/repository/DeviceRepository.java new file mode 100644 index 0000000..00a80c2 --- /dev/null +++ b/system/src/main/java/com/canvas/web/modules/device/repository/DeviceRepository.java @@ -0,0 +1,8 @@ +package com.canvas.web.modules.device.repository; + +import com.canvas.web.modules.device.domain.Device; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface DeviceRepository extends JpaRepository { + +} diff --git a/system/src/main/java/com/canvas/web/modules/device/rest/DeviceController.java b/system/src/main/java/com/canvas/web/modules/device/rest/DeviceController.java new file mode 100644 index 0000000..6311814 --- /dev/null +++ b/system/src/main/java/com/canvas/web/modules/device/rest/DeviceController.java @@ -0,0 +1,28 @@ +package com.canvas.web.modules.device.rest; + +import com.canvas.web.modules.device.domain.Device; +import com.canvas.web.modules.utils.Response; +import com.canvas.web.modules.utils.ResultUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequiredArgsConstructor +@Api(tags = "设备管理") +@RequestMapping("/api/device") +public class DeviceController { + @ApiOperation("设备列表") + @GetMapping("/list") + public Response>> list( + Pageable page + ){ + return null; + } +} diff --git a/system/src/main/java/com/canvas/web/modules/utils/Response.java b/system/src/main/java/com/canvas/web/modules/utils/Response.java new file mode 100644 index 0000000..349dcfc --- /dev/null +++ b/system/src/main/java/com/canvas/web/modules/utils/Response.java @@ -0,0 +1,78 @@ +package com.canvas.web.modules.utils; + +import com.canvas.web.modules.utils.enums.ResponseEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel(description = "结果返回类") +public class Response { + + @ApiModelProperty(value = "状态码") + private Integer code; + + @ApiModelProperty(value = "返回内容") + private String msg; + + @ApiModelProperty(value = "数据对象") + private T data; + + private long timestamp; + + + private Response(T data){ + this.code= ResponseEnum.SUCCESS.getCode(); + this.msg=ResponseEnum.SUCCESS.getMessage(); + this.timestamp=System.currentTimeMillis(); + this.data=data; + } + + private Response(ResponseEnum responseEnum){ + if (null==responseEnum){ + return; + } + this.code= responseEnum.getCode(); + this.msg= responseEnum.getMessage(); + } + + //成功时调用 + public static Response success() { + return success(null); + } + //成功时调用 + public static Response success(T data) { + return new Response(data); + } + + public static Response error(){ + return error(ResponseEnum.ERROR); + } + + public static Response error(ResponseEnum responseEnum){ + return new Response(responseEnum); + } + + public Integer getCode() { + return code; + } + + public Response setCode(Integer code) { + this.code = code; + return this; + } + + public String getMsg() { + return msg; + } + + public Response setMsg(String msg){ + this.msg=msg; + return this; + } + + public T getData() {return data;} + + public Response setData(T data){ + this.data=data; + return this; + } +} diff --git a/system/src/main/java/com/canvas/web/modules/utils/ResultUtils.java b/system/src/main/java/com/canvas/web/modules/utils/ResultUtils.java new file mode 100644 index 0000000..12a85b4 --- /dev/null +++ b/system/src/main/java/com/canvas/web/modules/utils/ResultUtils.java @@ -0,0 +1,142 @@ +package com.canvas.web.modules.utils; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import org.springframework.data.domain.Page; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@Getter +@Setter +public class ResultUtils { + + @ApiModelProperty(value = "返回数据") + private List content; + + @Getter(AccessLevel.NONE) + @ApiModelProperty(value = "返回数据") + private T contentT; + + @ApiModelProperty(value = "返回状态") + private boolean bReturn; + + @ApiModelProperty(value = "返回信息") + private String Msg; + + @ApiModelProperty(value = "是否有上一页") + private boolean hasPrevious; + + @ApiModelProperty(value = "是否有下一页") + private boolean hasNext; + + @ApiModelProperty(value = "总数量") + private long totalElements; + + @ApiModelProperty(value = "总页数") + private int totalPages; + + @ApiModelProperty(value = "当前页数") + private int number; + + @ApiModelProperty(value = "每页显示数量") + private int size; + + public ResultUtils() { } + + public ResultUtils(List content, boolean hasPrevious, boolean hasNext, long totalElements, int totalPages, int number, int size) { + this.content = content; + this.bReturn = true; + this.Msg = "OK"; + this.hasPrevious = hasPrevious; + this.hasNext = hasNext; + this.totalElements = totalElements; + this.totalPages = totalPages; + this.number = number; + this.size = size; + } + + public ResultUtils(T contentT) { + List tList = new ArrayList<>(); + tList.add(contentT); + this.content = tList; + this.bReturn = true; + this.Msg = "OK"; + this.hasPrevious = false; + this.hasNext = false; + this.totalElements = 1; + this.totalPages = 1; + this.number = 1; + this.size = 1; + } + + public ResultUtils(List content){ + this.content = content; + this.bReturn = true; + this.Msg = "OK"; + this.hasPrevious = false; + this.hasNext = false; + this.totalElements = content.size(); + this.totalPages = 1; + this.number = 1; + this.size = content.size(); + } + + public ResultUtils(boolean bReturn, String Msg){ + this.bReturn = bReturn; + this.Msg = Msg; + } + + /*** + * 单条数据返回 + * @param content 数据 + * @param 泛型类 + * @return 分页返回 + */ + public static ResultUtils getResult(T content) { + return (ResultUtils) new ResultUtils(Collections.singletonList(content)); + } + + /*** + * 多条数据返回 + * @param content 数据 + * @param 泛型类 + * @return 分页返回 + */ + public static ResultUtils> getResult(List content) { + return (ResultUtils>) new ResultUtils(content); + } + + /*** + * 多条数据分页返回 + * @param content 数据 + * @param pages 分页 + * @param 泛型类 + * @return 分页返回 + */ + public static ResultUtils> getResult(List content, Page pages) { + return (ResultUtils>) new ResultUtils(content, pages.hasPrevious(), pages.hasNext(), pages.getTotalElements(), pages.getTotalPages(), pages.getNumber() + 1, pages.getSize()); + } + + /*** + * 无返回时(添加、编辑、删除)返回成功 + * @return 无返回时(添加、编辑、删除)返回成功 + * @param 泛型类 + */ + public static ResultUtils Succsee(){ + return (ResultUtils) new ResultUtils(true,"OK"); + } + + /*** + * 无返回时(添加、编辑、删除)返回失败 + * @param Msg 返回信息 + * @param 泛型类 + * @return 无返回时(添加、编辑、删除)返回失败 + */ + public static ResultUtils Error(String Msg){ + return (ResultUtils) new ResultUtils(true,Msg); + } +} diff --git a/system/src/main/java/com/canvas/web/modules/utils/enums/ResponseEnum.java b/system/src/main/java/com/canvas/web/modules/utils/enums/ResponseEnum.java new file mode 100644 index 0000000..642c535 --- /dev/null +++ b/system/src/main/java/com/canvas/web/modules/utils/enums/ResponseEnum.java @@ -0,0 +1,126 @@ +package com.canvas.web.modules.utils.enums; + +import lombok.Getter; + +import java.util.HashMap; +import java.util.Map; + +@Getter +public enum ResponseEnum { + + /***************************************************通用日志信息****************************************************/ + + /**http code**/ + /**操作成功**/ + SUCCESS(200,"操作成功"), + /**操作失败**/ + FAIL(000,"操作失败"), + /**服务端异常**/ + ERROR(500,"系统内部错误"), + /**对象创建成功**/ + CREATED ( 201,"对象创建成功"), + /**请求已经被接受**/ + ACCEPTED(202,"请求已经被接受"), + /**操作已经执行成功,但是没有返回数据**/ + NO_CONTENT(204,"操作已经执行成功,但是没有返回数据"), + /**资源已被移除**/ + MOVED_PERM(301,"资源已被移除"), + /**重定向*/ + SEE_OTHER(303,"重定向"), + /**资源没有被修改**/ + NOT_MODIFIED(304,"资源没有被修改"), + /**参数列表错误(缺少,格式不匹配**/ + BAD_REQUEST(400,"参数列表错误(缺少,格式不匹配)"), + /**未授权**/ + UNAUTHORIZED(401,"未授权"), + /**访问受限,授权过期**/ + FORBIDDEN(403,"访问受限,授权过期"), + /**资源,服务未找到**/ + NOT_FOUND(404,"资源,服务未找到"), + /**不允许的http方法**/ + BAD_METHOD(405,"不允许的http方法"), + /**资源冲突,或者资源被锁**/ + CONFLICT(409,"资源冲突,或者资源被锁"), + /**不支持的数据,媒体类型**/ + UNSUPPORTED_TYPE(415,"不支持的数据,媒体类型"), + /**接口未实现**/ + NOT_IMPLEMENTED(501,"接口未实现"), + + + /*********************10000-登录相关***************************/ + /**登录模块**/ + LOGIN_SUCCESS(10000,"登录成功"), + LOGIN_FAIL(10001,"登录失败"), + LOGOUT_SUCCESS(10002,"退出成功"), + LOGOUT_FAIL(10003,"退出失败"), + TOKEN_ERROR(10004,"token错误/失效"), + + + /*********************20000-业务相关***************************/ + /** + * 重复提交 + **/ + REPEAT_SUBMIT(20000, "不允许重复提交,请稍后再试"), + ADD_FAIL(20001, "新增失败"), + ADD_SUCCESS(20003, "新增成功"), + DELETE_FAIL(20004, "删除失败"), + DELETE_SUCCESS(20005, "删除成功"), + UPDATE_FAIL(20006, "修改失败"), + UPDATE_SUCCESS(20007, "修改成功"), + QUERY_FAIL(20008, "查询失败"), + QUERY_SUCCESS(20009, "查询成功"), + + /** + * 角色模块 + **/ + ROLE_ADD_ERROR_EXIST_NAME(20010, "新增角色失败,角色名称已存在"), + ROLE_ADD_ERROR_EXIST_AUTHORITY(20011, "新增角色失败,角色权限已存在"), + ROLE_UPDATE_ERROR_EXIST_NAME(20012, "修改角色失败,角色名称已存在"), + ROLE_UPDATE_ERROR_EXIST_AUTHORITY(20013, "修改角色失败,角色权限已存在"), + ROLE_UPDATE_ERROR(20014, "修改角色失败"), + + /** + * 菜单模块 + **/ + MENU_ADD_ERROR_EXIST(20015, "新增菜单失败,菜单名称已存在"), + MENU_ADD_ERROR_HTTP(20016, "新增菜单失败,地址必须以http(s)://开头"), + MENU_ADD_ERROR_SELF(20017, "新增菜单失败,上级菜单不能选择自己"), + MENU_DELETE_ERROR_SUB(20018, "删除菜单失败,存在子菜单,不允许删除"), + MENU_DELETE_ERROR_ROLE(20019, "删除菜单失败,菜单已分配角色,不允许删除"), + MENU_UPDATE_ERROR_EXIST(20020, "修改菜单失败,菜单名称已存在"), + MENU_UPDATE_ERROR_HTTP(20021, "修改菜单失败,地址必须以http(s)://开头"), + MENU_UPDATE_ERROR_SELF(20022, "修改菜单失败,上级菜单不能选择自己"), + + /***其他****/ + ABNORMAL_PICTURE_UPLOAD(21000, "上传图片异常,请联系管理员"); + + + //成员变量 + private Integer code; + private String message; + + + //构造 + ResponseEnum(Integer code, String message) { + this.code = code; + this.message=message; + } + + + private static final Map ENUM_MAP=new HashMap(); + + static { + for (ResponseEnum item : values()){ + ENUM_MAP.put(item.getCode(),item); + } + } + + public static ResponseEnum getModelByKey(Integer code){ + if(code !=null){ + return ENUM_MAP.get(code); + } + return null; + } + + +}