提交 54dd9c08 作者: xiaowang

加入用户token及 服务数据

上级 b3e8c575
package com.mmc.pms.auth;
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
import java.util.Objects;
/**
* Author: geDuo
* Date: 2022/6/2 17:26
*/
@Configuration
public class DataFilterYml {
@Bean
public static PropertySourcesPlaceholderConfigurer loadYml() {
PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new ClassPathResource("not-check.yml"));
configurer.setProperties(Objects.requireNonNull(yaml.getObject()));
return configurer;
}
}
package com.mmc.pms.auth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author: zj
* @Date: 2023/5/28 10:52
*/
@Configuration
public class MvcConfiguration implements WebMvcConfigurer {
@Autowired
private TokenCheckHandleInterceptor tokenCheckHandleInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(tokenCheckHandleInterceptor);
WebMvcConfigurer.super.addInterceptors(registry);
}
}
package com.mmc.pms.auth;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import java.util.List;
/**
* @author: zj
* @Date: 2023/5/28 13:54
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "data-filter", ignoreUnknownFields = false)
@PropertySource("classpath:not-check.yml")
public class NotCheckUriConfig {
// 不需要验证token的请求地址
private List<String> notAuthPath;
// 不需要验证token的请求地址;// 不需要验证token的请求地址
private List<String> uploadPath;
}
package com.mmc.pms.auth;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.common.ResultEnum;
import com.mmc.pms.util.PathUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
/**
* @author: zj
* @Date: 2023/5/28 10:46
*/
@Slf4j
@Component
public class TokenCheckHandleInterceptor implements HandlerInterceptor {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private NotCheckUriConfig notCheckUriConfig;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String requestURI = request.getRequestURI();
// //根据uri确认是否要拦截
if (!shouldFilter(requestURI)) {
return true;
}
String token = request.getHeader("token");
if (StringUtils.isBlank(token)) {
exceptionProcess(response);
return false;
}
String tokenJson = stringRedisTemplate.opsForValue().get(token);
if (StringUtils.isBlank(tokenJson)) {
exceptionProcess(response);
return false;
}
//
// String serverName = request.getServerName();
// String remoteHost = request.getRemoteHost();
// log.info("hostName: {}", hostName);
// log.info("serverName: {}", serverName);
// log.info("remoteHost: {}", remoteHost);
// log.info("forwardedFor: {}", forwardedFor);
// log.info("forwardedHost: {}", forwardedHost);
// if (hostName.equals("iuav.mmcuav.cn") || hostName.equals("test.iuav.mmcuav.cn") || hostName.equals("www.iuav.shop") || hostName.equals("test.iuav.shop")){
// String token = request.getHeader("token");
// if (StringUtils.isBlank(token)){
// exceptionProcess(response);
// return false;
// }
// String tokenJson = stringRedisTemplate.opsForValue().get(token);
// if (StringUtils.isBlank(tokenJson)){
// exceptionProcess(response);
// return false;
// }
// return true;
// }
//测试-打印请求信息
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
}
public void exceptionProcess(HttpServletResponse response) throws Exception {
response.setContentType("application/json;charset=utf-8");
PrintWriter writer = response.getWriter();
writer.write(ResultBody.error(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR).toString());
writer.close();
}
private boolean shouldFilter(String path) {
// 路径与配置的相匹配,则执行过滤
for (String pathPattern : notCheckUriConfig.getNotAuthPath()) {
if (PathUtil.isPathMatch(pathPattern, path)) {
// 如果匹配
return false;
}
}
return true;
}
}
package com.mmc.pms.auth.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author 作者 geDuo
* @version 创建时间:2021年8月31日 下午8:06:14
* @explain 类说明
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LoginSuccessDTO implements Serializable {
private static final long serialVersionUID = -1200834589953161925L;
private String token;
private Integer userAccountId;
private String accountNo;
private Integer portType;
private String uid;
private String phoneNum;
private String userName;
private String nickName;
// private RoleInfoDTO roleInfo;
}
package com.mmc.pms.controller;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.group.Create;
import com.mmc.pms.model.group.Update;
import com.mmc.pms.model.qo.ServiceQO;
import com.mmc.pms.model.work.vo.ServiceVO;
import com.mmc.pms.service.BackstageTaskService;
import io.swagger.annotations.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* @Author LW
* @date 2023/6/6 10:41
* 概要:
*/
@Api(tags = {"后台-服务管理-模块"})
@RestController
@RequestMapping("/backstage/work")
public class BackstageTaskServiceController extends BaseController {
@Resource
private BackstageTaskService backstageTaskService;
@ApiOperation(value = "新增作业服务")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("addWorkService")
public ResultBody addWorkService(@Validated(Create.class) @RequestBody ServiceVO param, HttpServletRequest request) {
return backstageTaskService.addWorkService(param, this.getUserLoginInfoFromRedis(request).getUserAccountId());
}
@ApiOperation(value = "修改作业服务")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("updateWorkService")
public ResultBody updateWorkService(@Validated(Update.class) @RequestBody ServiceVO param) {
return backstageTaskService.updateById(param);
}
@ApiOperation(value = "删除作业服务")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("deleteWorkService")
public ResultBody deleteWorkService(@ApiParam("作业服务id") @RequestParam(value = "id") Integer id) {
return backstageTaskService.deleteById(id);
}
@ApiOperation(value = "查询作业服务")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("queryWorkService")
public ResultBody queryWorkService(@ApiParam("作业服务id") @RequestParam(value = "id") Integer id) {
return backstageTaskService.queryById(id);
}
@ApiOperation(value = "查询工作服务列表")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("queryWorkServiceList")
public ResultBody queryWorkServiceList(@Validated(Create.class) @RequestBody ServiceQO param, HttpServletRequest request) {
return backstageTaskService.queryWorkServiceList(param, this.getUserLoginInfoFromRedis(request).getUserAccountId());
}
}
package com.mmc.pms.controller;
import com.alibaba.fastjson.JSONObject;
import com.mmc.pms.auth.dto.LoginSuccessDTO;
import com.mmc.pms.common.ResultEnum;
import com.mmc.pms.util.BizException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import javax.servlet.http.HttpServletRequest;
/**
* @author: zj
* @Date: 2023/5/25 18:11
*/
public abstract class BaseController {
@Autowired
private StringRedisTemplate stringRedisTemplate;
/**
* 解析token,获取用户信息
* @param request
* @return
*/
// public BaseAccountDTO getUserLoginInfo(HttpServletRequest request) {
// String token = request.getHeader("token");
// try {
// Claims claims = JwtUtil.parseJwt(token);
// String userId = claims.get(JwtConstant.USER_ACCOUNT_ID).toString();
//// String roleId = claims.get("").toString();
// String tokenType = claims.get(JwtConstant.TOKEN_TYPE).toString();
// return BaseAccountDTO.builder().id(Integer.parseInt(userId)).tokenPort(tokenType).build();
// }catch (Exception e){
// throw new BizException("Invalid token");
// }
// }
/**
* 使用token从redis获取用户信息
*
* @param request
* @return
*/
public LoginSuccessDTO getUserLoginInfoFromRedis(HttpServletRequest request) {
String token = request.getHeader("token");
if (StringUtils.isBlank(token)) {
throw new BizException(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR);
}
String json = stringRedisTemplate.opsForValue().get(token);
if (StringUtils.isBlank(json)) {
throw new BizException(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR);
}
LoginSuccessDTO loginSuccessDTO = JSONObject.parseObject(json, LoginSuccessDTO.class);
return loginSuccessDTO;
}
}
package com.mmc.pms.dao;
import com.mmc.pms.entity.ServiceDO;
import com.mmc.pms.model.qo.ServiceQO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Author LW
* @date 2023/6/6 10:48
* 概要:
*/
@Mapper
public interface BackstageTaskServiceDao {
int insert(ServiceDO serviceDO);
int update(ServiceDO serviceDO);
int deleteById(Integer id);
ServiceDO queryById(Integer id);
List<ServiceDO> queryAllByLimit(ServiceQO param);
}
...@@ -110,6 +110,8 @@ public interface ProductDao { ...@@ -110,6 +110,8 @@ public interface ProductDao {
Set<Integer> listProductSpecIds(@Param("mallProdSkuSpecIds") Set<Integer> mallProdSkuSpecIds); Set<Integer> listProductSpecIds(@Param("mallProdSkuSpecIds") Set<Integer> mallProdSkuSpecIds);
List<OrderGoodsProdDTO> listProdGoodsSkuInfo(MallOrderGoodsInfoQO mallOrderGoodsInfoQO); List<OrderGoodsProdDTO> listProdGoodsSkuInfo(MallOrderGoodsInfoQO mallOrderGoodsInfoQO);
List<MallProdSkuInfoSpecDO> listMallProductSpec(Integer id);
} }
......
...@@ -16,21 +16,21 @@ import java.time.LocalDateTime; ...@@ -16,21 +16,21 @@ import java.time.LocalDateTime;
*/ */
@Data @Data
public class BaseEntity implements Serializable { public class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Integer id;
@ApiModelProperty("添加时间") @ApiModelProperty("添加时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime addtime; private LocalDateTime addtime;
@ApiModelProperty("最近一次编辑时间") @ApiModelProperty("最近一次编辑时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updatetime; private LocalDateTime updatetime;
@ApiModelProperty("1删除") @ApiModelProperty("1删除")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
@TableLogic @TableLogic
private Integer deleted; private Integer deleted;
} }
...@@ -59,6 +59,7 @@ public class ProductSkuDO implements Serializable { ...@@ -59,6 +59,7 @@ public class ProductSkuDO implements Serializable {
.productBrand(this.brandName) .productBrand(this.brandName)
.createTime(this.createTime) .createTime(this.createTime)
.categoriesId(categoriesId) .categoriesId(categoriesId)
.productBrandId(brandInfoId)
.directoryId(directoryId) .directoryId(directoryId)
.categoryName(this.categoryName) .categoryName(this.categoryName)
.directoryName(directoryName) .directoryName(directoryName)
......
package com.mmc.pms.entity; package com.mmc.pms.entity;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.mmc.pms.model.other.dto.RepoCashDTO; import com.mmc.pms.model.other.dto.RepoCashDTO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -20,53 +20,53 @@ import java.util.Date; ...@@ -20,53 +20,53 @@ import java.util.Date;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class RepoCashDO implements Serializable { public class RepoCashDO implements Serializable {
private static final long serialVersionUID = -7930603317037474755L; private static final long serialVersionUID = -7930603317037474755L;
private Integer id; private Integer id;
private Integer repoAccountId; private Integer repoAccountId;
private String uid; private String uid;
private String accountName; private String accountName;
private Integer orderInfoId; private Integer orderInfoId;
private String orderNo; private String orderNo;
private Integer skuInfoId; private Integer skuInfoId;
private String skuTitle; private String skuTitle;
private Integer wareInfoId; private Integer wareInfoId;
private String wareNo; private String wareNo;
private String wareTitle; private String wareTitle;
private String payNo; private String payNo;
private Integer payMethod; private Integer payMethod;
private BigDecimal amtPaid; private BigDecimal amtPaid;
private BigDecimal cashAmt; private BigDecimal cashAmt;
private Date payTime; private Date payTime;
private String refundNo; private String refundNo;
private String voucher; private String voucher;
private String remark; private String remark;
private Integer createUser; private Integer createUser;
private Date createTime; private Date createTime;
private Integer updateUser; private Integer updateUser;
private Date updateTime; private Date updateTime;
public RepoCashDTO buildRepoCashDTO() { public RepoCashDTO buildRepoCashDTO() {
return RepoCashDTO.builder() return RepoCashDTO.builder()
.id(this.id) .id(this.id)
.repoAccountId(this.repoAccountId) .repoAccountId(this.repoAccountId)
.uid(this.uid) .uid(this.uid)
.accountName(this.accountName) .accountName(this.accountName)
.orderInfoId(this.orderInfoId) .orderInfoId(this.orderInfoId)
.orderNo(this.orderNo) .orderNo(this.orderNo)
.skuInfoId(this.skuInfoId) .skuInfoId(this.skuInfoId)
.skuTitle(this.skuTitle) .skuTitle(this.skuTitle)
.wareInfoId(this.wareInfoId) .wareInfoId(this.wareInfoId)
.wareNo(this.wareNo) .wareNo(this.wareNo)
.wareTitle(this.wareTitle) .wareTitle(this.wareTitle)
.payNo(this.payNo) .payNo(this.payNo)
.payMethod(this.payMethod) .payMethod(this.payMethod)
.amtPaid(this.amtPaid) .amtPaid(this.amtPaid)
.refundNo(this.refundNo) .refundNo(this.refundNo)
.createUser(this.createUser) .createUser(this.createUser)
.voucher(StringUtils.isBlank(this.voucher) ? null : Arrays.asList(this.voucher.split(","))) .voucher(StringUtils.isBlank(this.voucher) ? null : Arrays.asList(this.voucher.split(",")))
.cashAmt(this.cashAmt) .cashAmt(this.cashAmt)
.payTime(this.payTime) .payTime(this.payTime)
.remark(this.remark) .remark(this.remark)
.build(); .build();
} }
} }
package com.mmc.pms.entity;
import com.mmc.pms.model.work.vo.ServiceVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @Author LW
* @date 2023/6/8 10:33
* 概要:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ServiceDO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
@ApiModelProperty(value = "服务名称")
private String serviceName;
@ApiModelProperty(value = "应用")
private Integer applicationId;
@ApiModelProperty(value = "行业")
private Integer industryId;
@ApiModelProperty(value = "展示状态")
private Integer displayState;
@ApiModelProperty(value = "封面图")
private String coverPlan;
@ApiModelProperty(value = "分享卡片")
private String shareCard;
@ApiModelProperty(value = "视频")
private String video;
@ApiModelProperty(value = "服务介绍")
private String serviceIntroduction;
@ApiModelProperty(value = "创建人id")
private Integer accountId;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "逻辑删除字段")
private Integer isDeleted;
public ServiceDO(ServiceVO param, Integer accountId) {
this.id = param.getId();
this.serviceName = param.getServiceName();
this.applicationId = param.getApplicationId();
this.industryId = param.getIndustryId();
this.displayState = param.getDisplayState();
this.coverPlan = param.getCoverPlan();
this.shareCard = param.getShareCard();
this.video = param.getVideo();
this.serviceIntroduction = param.getServiceIntroduction();
this.accountId = accountId;
}
public ServiceDO(ServiceVO param) {
this.id = param.getId();
this.serviceName = param.getServiceName();
this.applicationId = param.getApplicationId();
this.industryId = param.getIndustryId();
this.displayState = param.getDisplayState();
this.coverPlan = param.getCoverPlan();
this.shareCard = param.getShareCard();
this.video = param.getVideo();
this.serviceIntroduction = param.getServiceIntroduction();
}
public ServiceDO(Integer id, Integer accountId) {
this.id = id;
this.accountId = accountId;
}
}
...@@ -13,107 +13,107 @@ import java.util.List; ...@@ -13,107 +13,107 @@ import java.util.List;
*/ */
public class JsonUtil { public class JsonUtil {
public static void main(String[] args) { public static void main(String[] args) {
String array = "[1,24,23]"; String array = "[1,24,23]";
List<Integer> list = JSONArray.parseArray(array, Integer.class); List<Integer> list = JSONArray.parseArray(array, Integer.class);
System.out.println(list.get(2)); System.out.println(list.get(2));
} }
/** /**
* 把Java对象转换成json字符串 * 把Java对象转换成json字符串
* *
* @param object 待转化为JSON字符串的Java对象 * @param object 待转化为JSON字符串的Java对象
* @return json 串 or null * @return json 串 or null
*/ */
public static String parseObjToJson(Object object) { public static String parseObjToJson(Object object) {
String string = null; String string = null;
try { try {
string = JSONObject.toJSONString(object); string = JSONObject.toJSONString(object);
} catch (Exception e) { } catch (Exception e) {
// LOGGER.error(e.getMessage()); // LOGGER.error(e.getMessage());
}
return string;
} }
return string;
}
/** /**
* 将Json字符串信息转换成对应的Java对象 * 将Json字符串信息转换成对应的Java对象
* *
* @param json json字符串对象 * @param json json字符串对象
* @param c 对应的类型 * @param c 对应的类型
*/ */
public static <T> T parseJsonToObj(String json, Class<T> c) { public static <T> T parseJsonToObj(String json, Class<T> c) {
try { try {
JSONObject jsonObject = JSON.parseObject(json); JSONObject jsonObject = JSON.parseObject(json);
return JSON.toJavaObject(jsonObject, c); return JSON.toJavaObject(jsonObject, c);
} catch (Exception e) { } catch (Exception e) {
// LOGGER.error(e.getMessage()); // LOGGER.error(e.getMessage());
}
return null;
} }
return null;
}
/** /**
* 读取json文件 * 读取json文件
* *
* @param fileName * @param fileName
* @return * @return
*/ */
public static String readJsonFile(String fileName) { public static String readJsonFile(String fileName) {
String jsonStr = ""; String jsonStr = "";
try { try {
File jsonFile = new File(fileName); File jsonFile = new File(fileName);
FileReader fileReader = new FileReader(jsonFile); FileReader fileReader = new FileReader(jsonFile);
Reader reader = new InputStreamReader(new FileInputStream(jsonFile), "utf-8"); Reader reader = new InputStreamReader(new FileInputStream(jsonFile), "utf-8");
int ch = 0; int ch = 0;
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
while ((ch = reader.read()) != -1) { while ((ch = reader.read()) != -1) {
sb.append((char) ch); sb.append((char) ch);
} }
fileReader.close(); fileReader.close();
reader.close(); reader.close();
jsonStr = sb.toString(); jsonStr = sb.toString();
return jsonStr; return jsonStr;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
}
} }
}
/** /**
* 将JSON数据格式化并保存到文件中 * 将JSON数据格式化并保存到文件中
* *
* @param jsonData 需要输出的json数 * @param jsonData 需要输出的json数
* @param filePath 输出的文件地址 * @param filePath 输出的文件地址
* @return * @return
*/ */
public static boolean createJsonFile(Object jsonData, String filePath) { public static boolean createJsonFile(Object jsonData, String filePath) {
String content = String content =
JSON.toJSONString( JSON.toJSONString(
jsonData, jsonData,
SerializerFeature.PrettyFormat, SerializerFeature.PrettyFormat,
SerializerFeature.WriteMapNullValue, SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteDateUseDateFormat); SerializerFeature.WriteDateUseDateFormat);
// 标记文件生成是否成功 // 标记文件生成是否成功
boolean flag = true; boolean flag = true;
// 生成json格式文件 // 生成json格式文件
try { try {
// 保证创建一个新文件 // 保证创建一个新文件
File file = new File(filePath); File file = new File(filePath);
if (!file.getParentFile().exists()) { // 如果父目录不存在,创建父目录 if (!file.getParentFile().exists()) { // 如果父目录不存在,创建父目录
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
if (file.exists()) { // 如果已存在,删除旧文件 if (file.exists()) { // 如果已存在,删除旧文件
file.delete(); file.delete();
} }
file.createNewFile(); file.createNewFile();
// 将格式化后的字符串写入文件 // 将格式化后的字符串写入文件
Writer write = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); Writer write = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
write.write(content); write.write(content);
write.flush(); write.flush();
write.close(); write.close();
} catch (Exception e) { } catch (Exception e) {
flag = false; flag = false;
e.printStackTrace(); e.printStackTrace();
}
return flag;
} }
return flag;
}
} }
package com.mmc.pms.model.qo;
import com.mmc.pms.common.Page;
import com.mmc.pms.model.group.Freeze;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @Author LW
* @date 2023/6/8 10:33
* 概要:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ServiceQO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
@ApiModelProperty(value = "服务名称", example = "服务名称")
@Length(message = "最大不超过30字", max = 30)
private String serviceName;
@ApiModelProperty(value = "应用", example = "1")
private Integer applicationId;
@ApiModelProperty(value = "行业", example = "2")
private Integer industryId;
@ApiModelProperty(value = "页码", required = true)
@NotNull(message = "页码不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "每页显示数", required = true)
@NotNull(message = "每页显示数不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageSize;
}
package com.mmc.pms.model.work.vo;
import com.mmc.pms.model.group.Create;
import com.mmc.pms.model.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @Author LW
* @date 2023/6/8 10:33
* 概要:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ServiceVO implements Serializable {
private static final long serialVersionUID = 1L;
@NotNull(message = "修改服务id不能为空", groups = {Update.class})
private Integer id;
@ApiModelProperty(value = "服务名称", example = "服务名称")
@NotBlank(message = "服务名称不能为空", groups = {Create.class, Update.class})
@Length(message = "最大不超过30字", max = 30)
private String serviceName;
@ApiModelProperty(value = "应用", example = "1")
private Integer applicationId;
@ApiModelProperty(value = "行业", example = "2")
@NotNull(message = "行业id不能为空", groups = {Create.class, Update.class})
private Integer industryId;
@ApiModelProperty(value = "展示状态,0为上架,1下架", example = "0")
@NotNull(message = "展示状态不能为空", groups = {Create.class, Update.class})
private Integer displayState;
@ApiModelProperty(value = "封面图")
@NotBlank(message = "封面图不能为空", groups = {Create.class, Update.class})
private String coverPlan;
@ApiModelProperty(value = "分享卡片")
private String shareCard;
@ApiModelProperty(value = "视频")
private String video;
@ApiModelProperty(value = "服务介绍")
private String serviceIntroduction;
}
package com.mmc.pms.service;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.qo.ServiceQO;
import com.mmc.pms.model.work.vo.ServiceVO;
/**
* @Author LW
* @date 2023/6/6 10:46
* 概要:
*/
public interface BackstageTaskService {
ResultBody addWorkService(ServiceVO param, Integer userAccountId);
ResultBody updateById(ServiceVO param);
ResultBody deleteById(Integer id);
ResultBody queryById(Integer id);
ResultBody queryWorkServiceList(ServiceQO param, Integer userAccountId);
}
package com.mmc.pms.service.Impl;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.dao.BackstageTaskServiceDao;
import com.mmc.pms.entity.ServiceDO;
import com.mmc.pms.model.qo.ServiceQO;
import com.mmc.pms.model.work.vo.ServiceVO;
import com.mmc.pms.service.BackstageTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author LW
* @date 2023/6/8 9:59
* 概要:
*/
@Service
public class BackstageTaskServiceImpl implements BackstageTaskService {
@Autowired
private BackstageTaskServiceDao backstageTaskServiceDao;
@Override
public ResultBody addWorkService(ServiceVO param, Integer userAccountId) {
ServiceDO serviceDO = new ServiceDO(param, userAccountId);
backstageTaskServiceDao.insert(serviceDO);
return ResultBody.success();
}
@Override
public ResultBody updateById(ServiceVO param) {
ServiceDO serviceDO = new ServiceDO(param);
backstageTaskServiceDao.update(serviceDO);
return ResultBody.success();
}
@Override
public ResultBody deleteById(Integer id) {
backstageTaskServiceDao.deleteById(id);
return ResultBody.success();
}
@Override
public ResultBody queryById(Integer id) {
ServiceDO serviceDO = backstageTaskServiceDao.queryById(id);
return ResultBody.success(serviceDO);
}
@Override
public ResultBody queryWorkServiceList(ServiceQO param, Integer userAccountId) {
List<ServiceDO> services = backstageTaskServiceDao.queryAllByLimit(param);
return null;
}
}
...@@ -11,11 +11,11 @@ import com.mmc.pms.model.sale.dto.*; ...@@ -11,11 +11,11 @@ import com.mmc.pms.model.sale.dto.*;
import com.mmc.pms.model.sale.vo.ProductSpecCPQVO; import com.mmc.pms.model.sale.vo.ProductSpecCPQVO;
import com.mmc.pms.page.PageResult; import com.mmc.pms.page.PageResult;
import com.mmc.pms.service.ProductSkuService; import com.mmc.pms.service.ProductSkuService;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -226,7 +226,7 @@ public class ProductServiceImpl implements ProductSkuService { ...@@ -226,7 +226,7 @@ public class ProductServiceImpl implements ProductSkuService {
public ResultBody removeProductSpec(Integer id) { public ResultBody removeProductSpec(Integer id) {
// 根据规格id查询绑定的商品或者行业的sku // 根据规格id查询绑定的商品或者行业的sku
RemoveSkuDTO removeSkuDTO = new RemoveSkuDTO(); RemoveSkuDTO removeSkuDTO = new RemoveSkuDTO();
List<MallProdInfoDO> mallProdSkuInfoSpecList = productDao.listMallProdInfo(id.toString()); List<MallProdSkuInfoSpecDO> mallProdSkuInfoSpecList = productDao.listMallProductSpec(id);
// 拿到清单的id // 拿到清单的id
List<InventorySpecDO> inventorySpecList = productDao.listInventorySpec(id); List<InventorySpecDO> inventorySpecList = productDao.listInventorySpec(id);
if (mallProdSkuInfoSpecList.size() != 0 || inventorySpecList.size() != 0) { if (mallProdSkuInfoSpecList.size() != 0 || inventorySpecList.size() != 0) {
...@@ -237,7 +237,7 @@ public class ProductServiceImpl implements ProductSkuService { ...@@ -237,7 +237,7 @@ public class ProductServiceImpl implements ProductSkuService {
// 获取行业规格id // 获取行业规格id
Set<Integer> industrySpecIds = industryProductInventoryList.stream().map(IndustryProductInventoryDO::getIndustrySpecId).collect(Collectors.toSet()); Set<Integer> industrySpecIds = industryProductInventoryList.stream().map(IndustryProductInventoryDO::getIndustrySpecId).collect(Collectors.toSet());
// 分别获取规格对应的sku信息 // 分别获取规格对应的sku信息
List<IndustrySpecDO> industrySpecList = productDao.listIndustrySpec(industrySpecIds); List<IndustrySpecDO> industrySpecList = industrySpecDao.listIndustrySpec(industrySpecIds);
List<SkuAndSpecDTO> industrySkuNameList = new ArrayList<>(); List<SkuAndSpecDTO> industrySkuNameList = new ArrayList<>();
industrySpecList.stream().peek(d -> { industrySpecList.stream().peek(d -> {
SkuAndSpecDTO skuAndSpecDTO = new SkuAndSpecDTO(); SkuAndSpecDTO skuAndSpecDTO = new SkuAndSpecDTO();
......
package com.mmc.pms.util;
import com.mmc.pms.common.BaseErrorInfoInterface;
import com.mmc.pms.common.ResultEnum;
/**
* @author 作者 geDuo
* @version 创建时间:2021年8月13日 上午9:25:43
* @explain 类说明
*/
public class BizException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
* 错误码
*/
protected String errorCode;
/**
* 错误信息
*/
protected String errorMsg;
public BizException() {
super();
}
public BizException(BaseErrorInfoInterface errorInfoInterface) {
super(errorInfoInterface.getResultCode());
this.errorCode = errorInfoInterface.getResultCode();
this.errorMsg = errorInfoInterface.getResultMsg();
}
public BizException(BaseErrorInfoInterface errorInfoInterface, Throwable cause) {
super(errorInfoInterface.getResultCode(), cause);
this.errorCode = errorInfoInterface.getResultCode();
this.errorMsg = errorInfoInterface.getResultMsg();
}
public BizException(ResultEnum enums) {
super(enums.getResultCode());
this.errorCode = enums.getResultCode();
this.errorMsg = enums.getResultMsg();
}
public BizException(String errorMsg) {
super(errorMsg);
this.errorCode = "-1";
this.errorMsg = errorMsg;
}
public BizException(String errorCode, String errorMsg) {
super(errorCode);
this.errorCode = errorCode;
this.errorMsg = errorMsg;
}
public BizException(String errorCode, String errorMsg, Throwable cause) {
super(errorCode, cause);
this.errorCode = errorCode;
this.errorMsg = errorMsg;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
@Override
public String getMessage() {
return errorMsg;
}
@Override
public Throwable fillInStackTrace() {
return this;
}
}
package com.mmc.pms.util;
import org.springframework.util.AntPathMatcher;
/**
* @author 作者 geDuo
* @version 创建时间:2021年8月31日 下午3:29:28
* @explain 解析地址类
*/
public class PathUtil {
private static AntPathMatcher matcher = new AntPathMatcher();
public static boolean isPathMatch(String pattern, String path) {
return matcher.match(pattern, path);
}
}
...@@ -6,17 +6,22 @@ spring: ...@@ -6,17 +6,22 @@ spring:
username: tmj username: tmj
password: MMC@2022&MYSQL password: MMC@2022&MYSQL
redis: redis:
database: 3 database: 1
host: r-wz9ke310fs684hacn1.redis.rds.aliyuncs.com host: r-wz9ke310fs684hacn1pd.redis.rds.aliyuncs.com
port: 6379
password: MMC@2022&REDIS password: MMC@2022&REDIS
jedis: port: 6379
#连接池
lettuce:
shutdown-timeout: 1000 # 关闭超时时间-ms
pool: pool:
max-active: 2 #最大连接个数
servlet: max-active: 30
multipart: #等待时间-ms
max-file-size: 200MB max-wait: 1000ms
max-request-size: 200MB #最大空闲
max-idle: 8
#初始化最小
min-idle: 1
#mybatis-plus #mybatis-plus
mybatis-plus: mybatis-plus:
global-config: global-config:
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
set product_name = #{productName}, set product_name = #{productName},
categories_id = #{categoriesId}, categories_id = #{categoriesId},
model = #{model}, model = #{model},
brand_info_id = #{brandInfoId}, brand_info_id = #{brandInfoId}
where id = #{id} where id = #{id}
</update> </update>
<update id="updateProductSpec"> <update id="updateProductSpec">
update product_spec update product_spec
...@@ -279,7 +279,10 @@ ...@@ -279,7 +279,10 @@
and is_deleted = 0 and is_deleted = 0
</select> </select>
<select id="countSpecByProdSkuId" resultType="java.lang.Integer"> <select id="countSpecByProdSkuId" resultType="java.lang.Integer">
select count(*)
from product_spec
where product_id = #{id}
and is_deleted = 0
</select> </select>
<select id="listMallProdInfo" resultType="com.mmc.pms.entity.MallProdInfoDO"> <select id="listMallProdInfo" resultType="com.mmc.pms.entity.MallProdInfoDO">
SELECT mp.id, SELECT mp.id,
...@@ -314,7 +317,7 @@ ...@@ -314,7 +317,7 @@
mp.goods_info_id goodsInfoId, mp.goods_info_id goodsInfoId,
mp.mall_prod_info_id mallProdSkuInfoId, mp.mall_prod_info_id mallProdSkuInfoId,
gi.goods_name goodsName gi.goods_name goodsName
FROM mall_prod_sku_info_spec mp FROM mall_prod_info_spec mp
INNER JOIN goods_info gi ON gi.id = mp.goods_info_id INNER JOIN goods_info gi ON gi.id = mp.goods_info_id
WHERE mp.product_spec_id = #{id} WHERE mp.product_spec_id = #{id}
AND mp.is_deleted = 0 AND mp.is_deleted = 0
...@@ -334,8 +337,8 @@ ...@@ -334,8 +337,8 @@
ps.is_deleted as spec_deleted ps.is_deleted as spec_deleted
FROM FROM
goods_info gi goods_info gi
INNER JOIN mall_prod_sku_info mpsi ON gi.id = mpsi.goods_info_id INNER JOIN mall_prod_info mpsi ON gi.id = mpsi.goods_info_id
INNER JOIN mall_prod_sku_info_spec mpsip ON mpsi.id = mpsip.mall_prod_sku_info_id INNER JOIN mall_prod_info_spec mpsip ON mpsi.id = mpsip.mall_prod_sku_info_id
INNER JOIN product_spec ps ON ps.id = mpsip.product_spec_id INNER JOIN product_spec ps ON ps.id = mpsip.product_spec_id
<where> <where>
mpsip.id in ( mpsip.id in (
...@@ -386,7 +389,7 @@ ...@@ -386,7 +389,7 @@
</select> </select>
<select id="getProductSpecByIds" resultType="com.mmc.pms.entity.MallProdSkuInfoSpecDO"> <select id="getProductSpecByIds" resultType="com.mmc.pms.entity.MallProdSkuInfoSpecDO">
select id, goods_info_id goodsInfoId, mall_prod_info_id mallProdSkuInfoId, product_spec_id productSpecId select id, goods_info_id goodsInfoId, mall_prod_info_id mallProdSkuInfoId, product_spec_id productSpecId
from mall_prod_sku_info_spec from mall_prod_info_spec
where id in where id in
<foreach collection="list" separator="," item="d" open="(" close=")" index="index"> <foreach collection="list" separator="," item="d" open="(" close=")" index="index">
#{d} #{d}
...@@ -413,7 +416,7 @@ ...@@ -413,7 +416,7 @@
<collection property="orderGoodsProdDetailDTOS" ofType="com.mmc.pms.model.order.dto.OrderGoodsProdDetailDTO"> <collection property="orderGoodsProdDetailDTOS" ofType="com.mmc.pms.model.order.dto.OrderGoodsProdDetailDTO">
<result property="mallProdSkuInfoId" column="mall_prod_sku_info_id"/> <result property="mallProdSkuInfoId" column="mall_prod_sku_info_id"/>
<result property="unitName" column="unit_name"/> <result property="unitName" column="unit_name"/>
<result property="mallProdSkuInfoSpecId" column="mall_prod_sku_info_spec_id"/> <result property="mallProdSkuInfoSpecId" column="mall_prod_info_spec_id"/>
<result property="productSpecId" column="product_spec_id"/> <result property="productSpecId" column="product_spec_id"/>
<result property="specName" column="spec_name"/> <result property="specName" column="spec_name"/>
<result property="prodSkuSpecImage" column="prod_sku_spec_image"/> <result property="prodSkuSpecImage" column="prod_sku_spec_image"/>
...@@ -430,7 +433,8 @@ ...@@ -430,7 +433,8 @@
</collection> </collection>
</resultMap> </resultMap>
<select id="listProdGoodsSkuInfo" resultMap="listProdGoodsSkuInfoResultMap" parameterType="com.mmc.pms.model.qo.MallOrderGoodsInfoQO"> <select id="listProdGoodsSkuInfo" resultMap="listProdGoodsSkuInfoResultMap"
parameterType="com.mmc.pms.model.qo.MallOrderGoodsInfoQO">
SELECT SELECT
gi.id as goods_info_id,gi.goods_name,gi.goods_no,gi.directory_id, gi.id as goods_info_id,gi.goods_name,gi.goods_no,gi.directory_id,
gimg.img_url as mainImg, gimg.img_url as mainImg,
...@@ -464,4 +468,15 @@ ...@@ -464,4 +468,15 @@
) )
</where> </where>
</select> </select>
<select id="listMallProductSpec" resultType="com.mmc.pms.entity.MallProdSkuInfoSpecDO">
SELECT mp.id,
mp.goods_info_id goodsInfoId,
mp.mall_prod_info_id mallProdSkuInfoId,
gi.goods_name goodsName
FROM mall_prod_info_spec mp
INNER JOIN goods_info gi ON gi.id = mp.goods_info_id
WHERE mp.product_spec_id = #{id}
AND mp.is_deleted = 0
AND gi.is_deleted = 0
</select>
</mapper> </mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mmc.pms.dao.BackstageTaskServiceDao">
<resultMap type="com.mmc.pms.entity.ServiceDO" id="ServiceMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="serviceName" column="service_name" jdbcType="VARCHAR"/>
<result property="applicationId" column="application_id" jdbcType="INTEGER"/>
<result property="industryId" column="industry_id" jdbcType="INTEGER"/>
<result property="displayState" column="display_state" jdbcType="INTEGER"/>
<result property="coverPlan" column="cover_plan" jdbcType="VARCHAR"/>
<result property="shareCard" column="share_card" jdbcType="VARCHAR"/>
<result property="video" column="video" jdbcType="VARCHAR"/>
<result property="serviceIntroduction" column="service_introduction" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
<result property="accountId" column="account_id" jdbcType="INTEGER"/>
</resultMap>
<!--查询所有-->
<select id="queryAll" resultMap="ServiceMap">
select id,
service_name,
application_id,
industry_id,
display_state,
cover_plan,
share_card,
video,
service_introduction,
create_time,
update_time,
is_deleted,
account_id
from service
</select>
<!--查询单个-->
<select id="queryById" resultMap="ServiceMap">
select id,
service_name,
application_id,
industry_id,
display_state,
cover_plan,
share_card,
video,
service_introduction,
create_time,
update_time,
account_id
from service
where id = #{id}
and is_deleted = 0
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="ServiceMap" parameterType="com.mmc.pms.model.qo.ServiceQO">
select
id, service_name, application_id, industry_id, display_state, cover_plan, share_card, video,
service_introduction, create_time, update_time, account_id
from service
<where>
<if test="serviceName != null and serviceName != ''">
and service_name = #{serviceName}
</if>
<if test="applicationId != null">
and application_id = #{applicationId}
</if>
<if test="industryId != null">
and industry_id = #{industryId}
</if>
<if test="accountId != null">
and account_id = #{accountId}
</if>
and is_deleted = 0
and display_state = 0
</where>
order by create_time desc
limit #{pageNo}, #{pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from service
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="serviceName != null and serviceName != ''">
and service_name = #{serviceName}
</if>
<if test="applicationId != null">
and application_id = #{applicationId}
</if>
<if test="industryId != null">
and industry_id = #{industryId}
</if>
<if test="displayState != null">
and display_state = #{displayState}
</if>
<if test="coverPlan != null and coverPlan != ''">
and cover_plan = #{coverPlan}
</if>
<if test="shareCard != null and shareCard != ''">
and share_card = #{shareCard}
</if>
<if test="video != null and video != ''">
and video = #{video}
</if>
<if test="serviceIntroduction != null and serviceIntroduction != ''">
and service_introduction = #{serviceIntroduction}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="isDeleted != null">
and is_deleted = #{isDeleted}
</if>
<if test="accountId != null">
and account_id = #{accountId}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true" parameterType="com.mmc.pms.entity.ServiceDO">
insert into service(service_name, application_id, industry_id, display_state, cover_plan, share_card, video,
service_introduction, account_id)
values (#{serviceName}, #{applicationId}, #{industryId}, #{displayState}, #{coverPlan}, #{shareCard},
#{video}, #{serviceIntroduction}, #{accountId})
</insert>
<!--通过主键修改数据-->
<update id="update" parameterType="com.mmc.pms.entity.ServiceDO">
update service
<set>
<if test="serviceName != null and serviceName != ''">
service_name = #{serviceName},
</if>
<if test="applicationId != null">
application_id = #{applicationId},
</if>
<if test="industryId != null">
industry_id = #{industryId},
</if>
<if test="displayState != null">
display_state = #{displayState},
</if>
<if test="coverPlan != null and coverPlan != ''">
cover_plan = #{coverPlan},
</if>
<if test="shareCard != null and shareCard != ''">
share_card = #{shareCard},
</if>
<if test="video != null and video != ''">
video = #{video},
</if>
<if test="serviceIntroduction != null and serviceIntroduction != ''">
service_introduction = #{serviceIntroduction},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="accountId != null">
account_id = #{accountId},
</if>
</set>
where = #{id}
</update>
<!--通过主键删除-->
<update id="deleteById" parameterType="java.lang.Integer">
update service
set is_deleted = 1
where = #{id}
</update>
</mapper>
\ No newline at end of file
data-filter:
uploadPath: #不需要解析的body参数的地址
- /xxx/x
not-auth-path:
- /pms/v2/**
- /pms/doc.html
- /pms/swagger-resources/**
- /pms/webjars/**
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论