.idea/compiler.xml
@@ -7,8 +7,8 @@ <sourceOutputDir name="target/generated-sources/annotations" /> <sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> <outputRelativeToContentRoot value="true" /> <module name="ycl-platform" /> <module name="ycl-common" /> <module name="ycl-platform" /> </profile> </annotationProcessing> </component> ycl-common/src/main/java/com/ycl/config/IgnoreUrlsConfig.java
@@ -1,20 +1,22 @@ package com.ycl.config; import lombok.Getter; import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; import java.util.ArrayList; import java.util.List; /** * 用于配置白名单资源路径 */ @Getter @Setter @ConfigurationProperties(prefix = "secure.ignored") public class IgnoreUrlsConfig { private List<String> urls = new ArrayList<>(); } package com.ycl.config; import lombok.Getter; import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; /** * 用于配置白名单资源路径 */ @Getter @Setter @Component @ConfigurationProperties(prefix = "secure.ignored") public class IgnoreUrlsConfig { private List<String> urls = new ArrayList<>(); } ycl-platform/src/main/java/com/ycl/config/Intercept.java
@@ -14,6 +14,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; import java.util.stream.Collectors; @@ -25,14 +26,18 @@ NewsIpService newsIpService; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { List<String> ips = newsIpService.list().stream().map(item->item.getIpAddess()).collect(Collectors.toList()); if (!ips.contains(request.getRemoteAddr())){ return false; } String token = request.getHeader("token"); System.out.println(token); JwtTokenUtil jwtTokenUtil = new JwtTokenUtil(); if (token==null||token.isEmpty()){ // response.sendRedirect(""); // return true; throw new ApiException("用户未登录"); } AuthInfo authInfo = jwtTokenUtil.parseToken(token); if (authInfo == null) { throw new ApiException("未认证用户"); ycl-platform/src/main/java/com/ycl/config/WebMvcConfig.java
@@ -1,5 +1,6 @@ package com.ycl.config; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; @@ -13,10 +14,14 @@ return new Intercept(); } @Autowired IgnoreUrlsConfig urlsConfig; @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(this.Intercept()) //需要验证请求路径 /*代表全部 .addPathPatterns("/newsAdmin/login"); .addPathPatterns("/*") .excludePathPatterns(urlsConfig.getUrls()); } } ycl-platform/src/main/java/com/ycl/controller/ImageUploadController.java
@@ -21,7 +21,7 @@ @RequestMapping("upload") @Api(tags = "图片上传") public class ImageUploadController { @ApiOperation(value="/image", notes = "上传图片") @ApiOperation(value="上传图片") @RequestMapping(value = "/image", method = RequestMethod.POST) public CommonResult uploadImage(HttpServletRequest request, MultipartFile image) throws IOException { ycl-platform/src/main/java/com/ycl/controller/NewsAdminController.java
@@ -50,6 +50,7 @@ } else { if (admin.getPassword().equals(MD5Util.md5Encrypt32Lower(loginParam.getPassword()))) { JwtTokenUtil jwtTokenUtil = new JwtTokenUtil(); return CommonResult.success(jwtTokenUtil.generateToken(admin.getId(), admin.getUsername())); } else { return CommonResult.failed("密码错误"); ycl-platform/src/main/java/com/ycl/controller/NewsIpController.java
@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ycl.entity.NewsIp; import com.ycl.service.NewsIpService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -22,6 +24,7 @@ */ @RestController @RequestMapping("newsIp") @Api(tags = "ip管理") public class NewsIpController extends ApiController { /** * 服务对象 @@ -37,6 +40,7 @@ * @return 所有数据 */ @GetMapping @ApiOperation("查询所有") public R selectAll(Page<NewsIp> page, NewsIp newsIp) { return success(this.newsIpService.page(page, new QueryWrapper<>(newsIp))); } @@ -48,6 +52,7 @@ * @return 单条数据 */ @GetMapping("{id}") @ApiOperation("按id查询") public R selectOne(@PathVariable Serializable id) { return success(this.newsIpService.getById(id)); } @@ -59,6 +64,7 @@ * @return 新增结果 */ @PostMapping @ApiOperation("新增") public R insert(@RequestBody NewsIp newsIp) { return success(this.newsIpService.save(newsIp)); } @@ -70,6 +76,7 @@ * @return 修改结果 */ @PutMapping @ApiOperation("修改") public R update(@RequestBody NewsIp newsIp) { return success(this.newsIpService.updateById(newsIp)); } @@ -81,6 +88,7 @@ * @return 删除结果 */ @DeleteMapping @ApiOperation("删除") public R delete(@RequestParam("idList") List<Long> idList) { return success(this.newsIpService.removeByIds(idList)); } ycl-platform/src/main/java/com/ycl/controller/NewsPoliceController.java
@@ -73,7 +73,7 @@ */ @Transactional(rollbackFor = SQLException.class) @PostMapping @ApiOperation(value = "新增数据") @ApiOperation(value = "新增警员并注册") public R insert(@RequestBody NewsPolice newsPolice) { this.newsPoliceService.save(newsPolice); return success(newsAdminService.autoCreateAdmin(newsPolice)); ycl-platform/src/main/java/com/ycl/entity/NewsAdmin.java
@@ -2,6 +2,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.util.Date; @@ -13,37 +15,49 @@ */ @SuppressWarnings("serial") public class NewsAdmin extends Model<NewsAdmin> { private Long id; @ApiModelProperty("主键") private Integer id; //用户姓名 @ApiModelProperty("用户姓名") private String username; //密码 @ApiModelProperty("密码") private String password; //头像 @ApiModelProperty("头像") private String icon; //邮箱 @ApiModelProperty("邮箱") private String email; //备注信息 @ApiModelProperty("备注信息") private String note; //创建时间 @ApiModelProperty("创建时间") private Date createTime; //帐号启用状态:0->禁用;1->启用 @ApiModelProperty("帐号启用状态") private Integer status; // 0->女,1->男 @ApiModelProperty("性别") private Integer sex; //手机 @ApiModelProperty("手机") private String mobile; //是否为网格管理员:0->不是;1->是 @ApiModelProperty("是否为管理员") private Integer isGrid; //警员id @ApiModelProperty("警员id") private Integer newsPoliceId; public Long getId() { public Integer getId() { return id; } public void setId(Long id) { public void setId(Integer id) { this.id = id; } ycl-platform/src/main/java/com/ycl/entity/NewsChannel.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.sql.Date; @@ -17,15 +18,20 @@ @SuppressWarnings("serial") public class NewsChannel extends Model<NewsChannel> { //id @ApiModelProperty("主键") private Integer id; //频道名称 @ApiModelProperty("频道名称") private String name; //频道编码ps名称首字母 @ApiModelProperty("频道编码") private String code; //创建时间 @ApiModelProperty("创建时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; //栏目id @ApiModelProperty("栏目id") private List<String> columnId; public List<String> getColumnId() { ycl-platform/src/main/java/com/ycl/entity/NewsChannelColumn.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Builder; @@ -17,11 +18,13 @@ @Builder @AllArgsConstructor public class NewsChannelColumn extends Model<NewsChannelColumn> { @ApiModelProperty("主键") private Integer id; //频道id @ApiModelProperty("频道id") private Integer channelId; //栏目id @ApiModelProperty("栏目id") private Integer columnId; public Integer getId() { ycl-platform/src/main/java/com/ycl/entity/NewsColumn.java
@@ -2,6 +2,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; /** @@ -13,8 +15,10 @@ @SuppressWarnings("serial") public class NewsColumn extends Model<NewsColumn> { //id @ApiModelProperty("主键") private Integer id; //栏目名称 @ApiModelProperty("栏目名称") private String name; ycl-platform/src/main/java/com/ycl/entity/NewsColumnInformation.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.NoArgsConstructor; @@ -19,11 +20,13 @@ @NoArgsConstructor @AllArgsConstructor public class NewsColumnInformation extends Model<NewsColumnInformation> { @ApiModelProperty("主键") private Integer id; //栏目id @ApiModelProperty("栏目id") private Integer columnId; //咨询id //资讯id @ApiModelProperty("资讯id") private Integer informationId; ycl-platform/src/main/java/com/ycl/entity/NewsDepartment.java
@@ -2,6 +2,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; /** @@ -12,9 +14,10 @@ */ @SuppressWarnings("serial") public class NewsDepartment extends Model<NewsDepartment> { @ApiModelProperty("主键") private Integer id; //部门名称 @ApiModelProperty("部门名称") private String deptname; ycl-platform/src/main/java/com/ycl/entity/NewsDuty.java
@@ -2,6 +2,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.sql.Date; @@ -13,15 +15,19 @@ */ @SuppressWarnings("serial") public class NewsDuty extends Model<NewsDuty> { @ApiModelProperty("主键") private Integer id; //值班人 //值班人姓名 @ApiModelProperty("值班人") private String name; //值班职位 //值班内容 @ApiModelProperty("值班内容") private String jobTitle; //创建时间 @ApiModelProperty("创建时间") private Date createTime; //值班时间 @ApiModelProperty("值班日期") private Date dutyTime; ycl-platform/src/main/java/com/ycl/entity/NewsInformation.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.sql.Date; @@ -17,26 +18,36 @@ @SuppressWarnings("serial") public class NewsInformation extends Model<NewsInformation> { //id @ApiModelProperty("主键") private Integer id; //标题 @ApiModelProperty("标题") private String title; //内容 @ApiModelProperty("内容") private String content; //发布时间 @ApiModelProperty("发布时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date publishTime; //是否需要签收0需要签收1不需要签收 //是否需要签收-0需要签收1不需要签收 @ApiModelProperty("是否需要签收") private Integer isSign; //创建时间 @ApiModelProperty("创建时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; //警员id @ApiModelProperty("警员id") private Integer sendTo; //图片地址 @ApiModelProperty("图片地址") private String imageUrl; //部门(机构)id @ApiModelProperty("部门(机构)id") private List<String> departmentId; //栏目id @ApiModelProperty("栏目id") private List<String> columnId; public List<String> getColumnId() { ycl-platform/src/main/java/com/ycl/entity/NewsInformationPolice.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.NoArgsConstructor; @@ -19,13 +20,16 @@ @NoArgsConstructor @AllArgsConstructor public class NewsInformationPolice extends Model<NewsInformationPolice> { @ApiModelProperty("主键") private Integer id; //资讯id @ApiModelProperty("资讯id") private Integer newsInformationId; //警员id @ApiModelProperty("警员id") private Integer newsPoliceId; //是否签收0未签收1签收2不需要签收 //是否签收-0未签收1签收2不需要签收 @ApiModelProperty("是否签收") private Integer isSign; ycl-platform/src/main/java/com/ycl/entity/NewsIp.java
@@ -2,6 +2,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.sql.Date; @@ -13,11 +15,13 @@ */ @SuppressWarnings("serial") public class NewsIp extends Model<NewsIp> { @ApiModelProperty("主键") private Integer id; //ip地址 @ApiModelProperty("ip地址") private String ipAddess; //创建时间 @ApiModelProperty("创建时间") private Date createTime; ycl-platform/src/main/java/com/ycl/entity/NewsPolice.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.sql.Date; @@ -17,18 +18,24 @@ @SuppressWarnings("serial") public class NewsPolice extends Model<NewsPolice> { //自增主键 @ApiModelProperty("主键") private Integer id; //警员名称 @ApiModelProperty("警员名称") private String rname; //创建时间 @ApiModelProperty("创建时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") //修改时间 @ApiModelProperty("修改时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date updateTime; //机构id @ApiModelProperty("机构id") private String newsDepartmentId; //手机号码 @ApiModelProperty("手机号码") private String phone; ycl-platform/src/main/resources/application.yml
@@ -60,3 +60,17 @@ #true则是生产环境不允许访问knife4j production: false secure: ignored: urls: - /swagger-ui.html - /swagger/** - /swagger-ui/* - /swagger-resources/** - /**/v2/api-docs - /doc.html - /**/*.html - /**/*.js - /**/*.css - /**/*.png - /newsAdmin/login