提交 2224160d authored 作者: xc's avatar xc

xc

上级 991db5a5
...@@ -10,6 +10,38 @@ ...@@ -10,6 +10,38 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>efs-bus</artifactId> <artifactId>efs-bus</artifactId>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.51</version>
</dependency>
<dependency>
<groupId>com.zjty</groupId>
<artifactId>efs-misc</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.18</version>
</dependency>
</dependencies>
</project> </project>
\ No newline at end of file
package com.zjty.efs.bus;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
@ComponentScan(basePackages = {
"com.zjty.efs.misc",
"com.zjty.efs.bus"
})
@EnableSwagger2
public class BusApplication {
public static void main(String[] args) {
SpringApplication.run(BusApplication.class, args);
}
}
package com.zjty.efs.bus.Dao;
import com.zjty.efs.bus.entity.Notice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface NoticeDao extends JpaRepository<Notice , Integer> {
}
package com.zjty.efs.bus.controller;
import com.alibaba.fastjson.JSONObject;
import com.zjty.efs.bus.entity.Notice;
import com.zjty.efs.bus.service.NoticeService;
import com.zjty.efs.misc.config.AutoDocument;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@AutoDocument
@Api(tags = "通知接口")
@RestController
@RequestMapping("/notice")
public class NoticeController {
@Autowired
private NoticeService noticeService;
@ApiOperation(value = "测试接口")
@ApiImplicitParam(name = "notice", value = "", dataType = "String", paramType = "query", required = true)
@PostMapping("/testNotice")
public String test(@RequestParam String notice){
System.out.println(notice);
return "test";
}
/**
* 新增通知
* @param notice
* @return
*/
@ApiOperation(value = "新增通知接口")
@ApiImplicitParam(name = "notice", value = "通知实体", dataType = "Notice", paramType = "body", required = true)
@PostMapping("/addNotice")
public String addNotice(@RequestBody @Valid Notice notice){
System.out.println(notice);
return noticeService.addNotice(notice);
}
/**
* 修改通知
* @param notice
* @return
*/
@ApiOperation(value = "修改通知接口")
@ApiImplicitParam(name = "notice", value = "通知实体", dataType = "Notice", paramType = "body", required = true)
@PostMapping("/updateNotice")
public String updateNotice(@RequestBody @Valid Notice notice){
System.out.println(notice);
return noticeService.updateNotice(notice);
}
@ApiOperation(value = "查看通知接口")
@ApiImplicitParam(name = "id", value = "通知id", paramType = "query",
required = true, example = "1")
@PostMapping("/getNotice")
public String getNotice(@RequestParam int id){
System.out.println(id);
return noticeService.getNotice(id);
}
@PostMapping("/getNoticeList")
@ApiOperation(value = "获取通知列表接口", notes = "获取列表,type为通知类型,接收 0,发送 1,草稿 2,消息提醒 0")
@ApiImplicitParams({@ApiImplicitParam(name = "user", value = "当前用户名称", paramType = "query", required = true, example = "username", dataType = "String"),
@ApiImplicitParam(name = "type", value = "通知类型", paramType = "query", required = true, example = "0", dataType = "int")})
public String getNoticeList(@RequestParam String user, int type){
return noticeService.getReceiveList(user, type);
}
}
package com.zjty.efs.bus.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class FileList {
private String id;
private String address;
}
package com.zjty.efs.bus.entity;
import com.zjty.efs.misc.config.AutoDocument;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Generated;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
/**
* 通知表
*/
@AutoDocument
//@ApiModel(value = "通知", description = "通知实体类")
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "notice")
public class Notice {
/**
* id
*/
@ApiModelProperty(value = "id", example = "1")
@Id
@GeneratedValue
@Column(name = "id")
private int id;
/**
* 标题
*/
@ApiModelProperty(value = "title", example = "验收通知", dataType = "String", name = "标题")
@Column(name = "title")
private String title;
/**
* 收件人
*/
@ApiModelProperty(value = "addressee", example = "谢潮", dataType = "String", name = "收件人")
@Column(name = "addressee")
private String addressee;
/**
* 发件人
*/
@ApiModelProperty(value = "sender", example = "谢借口", dataType = "String", name = "发件人")
@Column(name = "sender")
private String sender;
/**
* 留言
*/
@ApiModelProperty(value = "message", example = "尽快完成", dataType = "String", name = "留言")
@Column(name = "message")
private String message;
/**
* 通知状态 已查看 0,未查看 1,已下载 2
*/
@ApiModelProperty(value = "status", example = "0", dataType = "int" ,name = "通知状态",
notes = "未查看 0,已查看 1,已下载 2,默认 0")
@Column(name = "status")
private int status;
/**
* 通知类型 接受 0,发送 1,草稿 2
*/
@ApiModelProperty(value = "type", example = "0", dataType = "int", name = "通知类型",
notes = "接收 0,发送 1,草稿 2,默认 0")
@Column(name = "type")
private int type;
/**
* 失效时间
*/
@ApiModelProperty(value = "deadline", example = "2020-02-12 10:23:12", name = "通知失效时间")
@Column(name = "deadline")
private Date deadline;
/**
* 通知更新时间
*/
@ApiModelProperty(value = "updateTime", example = "2020-02-12 10:23:12", name = "通知更新时间")
@Column(name = "update_time")
private Date updateTime;
/**
* 是否推送短信 是 0,否 1
*/
@ApiModelProperty(value = "note", example = "0", dataType = "int", name = "是否推送短信")
@Column(name = "note")
private int note;
/**
* 附件列表
*/
@ApiModelProperty(value = "fileList", example = "", dataType = "list", name = "附件列表")
@Column(name = "file_list")
private String fileList;
}
package com.zjty.efs.bus.service;
import com.alibaba.fastjson.JSONObject;
import com.zjty.efs.bus.entity.Notice;
public interface NoticeService {
/**
* 新增通知
* @param jsonObject 通知json对象
* @return
*/
String addNotice(Notice jsonObject);
/**
* 修改通知
* @param jsonObject 通知json对象
* @return
*/
String updateNotice(Notice jsonObject);
/**
* 查看通知
* @param id
* @return
*/
String getNotice(int id);
/**
* 获取通知列表
* @param user 登录用户
*
* type 通知类型 接受 0,发送 1,草稿 2
*
* @return 通知json对象
*/
String getReceiveList(String user, int type);
}
package com.zjty.efs.bus.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.zjty.efs.bus.Dao.NoticeDao;
import com.zjty.efs.bus.entity.Notice;
import com.zjty.efs.bus.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class NoticeServiceImpl implements NoticeService {
@Autowired
NoticeDao noticeDao;
@Override
public String addNotice(Notice jsonObject) {
return "成功";
}
@Override
public String updateNotice(Notice jsonObject) {
return null;
}
@Override
public String getNotice(int id) {
return null;
}
@Override
public String getReceiveList(String user, int type) {
return null;
}
}
##连接mysql
spring.datasource.url=jdbc:mysql://localhost:3306/efs-notice?useSSL=false&serverTimezone=UTC&characterEncoding=UTF-8
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.properties.hibernate.format_sql=true
spring.main.allow-bean-definition-overriding=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
#spring.jackson.serialization.write-dates-as-timestamps=false
\ No newline at end of file
...@@ -47,6 +47,21 @@ ...@@ -47,6 +47,21 @@
<artifactId>springfox-bean-validators</artifactId> <artifactId>springfox-bean-validators</artifactId>
<version>${swagger.version}</version> <version>${swagger.version}</version>
</dependency> </dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-core</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spi</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-web</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论