提交 237a9776 编写于 作者: 是赵敢敢啊's avatar 是赵敢敢啊

字典项相关提交

上级 26bd0046
此差异已折叠。
......@@ -47,10 +47,6 @@ public class LogAspect {
@Autowired
private SysOperationLogService logService;
// 配置织入点
@Pointcut("@annotation(net.lesscoding.handmade.aspect.Log)")
public void logPointCut() {
}
@Value(value = "${server.port}")
private String port;
......@@ -58,6 +54,15 @@ public class LogAspect {
private Long methodIntervalMs = 1L;
/** 当前登录的id */
private String loginId = "1";
@Autowired
private Gson gson;
// 配置织入点
@Pointcut("@annotation(net.lesscoding.handmade.aspect.Log)")
public void logPointCut() {
}
/**
* 处理完请求后执行
*
......@@ -95,7 +100,7 @@ public class LogAspect {
operLog.setUserAgent(UserAgentUtil.userAgent());
operLog.setOperIp(ip);
// 返回参数
operLog.setJsonResult(new Gson().toJson(jsonResult));
operLog.setJsonResult(gson.toJson(jsonResult));
operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
if (e != null) {
operLog.setStatus(1);
......@@ -147,7 +152,7 @@ public class LogAspect {
// 打印耗时的信息
methodIntervalMs = timer.intervalMs();
log.info("----------{}执行耗时{}ms----------", methodName, methodIntervalMs);
log.info("----------{}返回参数----------\n{}", methodName, new Gson().toJson(obj));
log.info("----------{}返回参数----------\n{}", methodName, gson.toJson(obj));
return obj;
}
......@@ -212,7 +217,7 @@ public class LogAspect {
for (int i = 0; i < paramsArray.length; i++) {
if (!isFilterObject(paramsArray[i])) {
//Object jsonObj = JSON.toJSON(paramsArray[i]);
params += new Gson().toJson(paramsArray[i]) + " ";
params += gson.toJson(paramsArray[i]) + " ";
}
}
}
......
......@@ -61,6 +61,7 @@ public class BaseEntity<T>{
private Boolean delFlag;
@JsonIgnore
@TableField(exist = false)
private PageDto page;
}
......@@ -17,7 +17,7 @@ import java.util.stream.Collectors;
/**
* @author eleven
* @date 2023/6/28 10:05
* @apiNote
* @apiNote 解决高版本Springboot导致Knife4j运行空指针问题
*/
@Slf4j
@Configuration
......
......@@ -5,10 +5,7 @@ import net.lesscoding.handmade.common.ResultFactory;
import net.lesscoding.handmade.entity.Dict;
import net.lesscoding.handmade.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* @author eleven
......@@ -27,4 +24,9 @@ public class DictController {
return ResultFactory.success(dictService.saveOrUpdate(dict));
}
@GetMapping("/dictList")
public Result dictList(Dict dict) {
return ResultFactory.success(dictService.dictList(dict));
}
}
package net.lesscoding.handmade.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.lesscoding.handmade.aspect.Log;
import net.lesscoding.handmade.common.Result;
import net.lesscoding.handmade.common.ResultFactory;
import net.lesscoding.handmade.entity.Supplier;
import net.lesscoding.handmade.enums.BusinessType;
import net.lesscoding.handmade.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* @author eleven
* @date 2023/6/28 19:55
* @apiNote
*/
@Api(tags = "供应商管理")
@RestController
@RequestMapping("/supplier")
public class SupplierController {
......@@ -23,7 +25,16 @@ public class SupplierController {
private SupplierService supplierService;
@PostMapping("/editSupplier")
@ApiOperation(value = "编辑供应商信息")
@Log(title = "编辑供应商信息", businessType = BusinessType.UPDATE)
public Result editSupplier(@RequestBody Supplier supplier) {
return ResultFactory.success(supplierService.saveOrUpdate(supplier));
}
@GetMapping("/allSupplier")
@ApiOperation(value = "所有供应商")
@Log(title = "获取所有供应商", businessType = BusinessType.SELECT)
public Result allSupplier() {
return ResultFactory.success(supplierService.list());
}
}
......@@ -3,10 +3,13 @@ package net.lesscoding.handmade.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lesscoding.handmade.entity.Dict;
import java.util.List;
/**
* @author eleven
* @date 2023/6/28 19:35
* @apiNote 字典项mapper
*/
public interface DictMapper extends BaseMapper<Dict> {
List<Dict> getDictList(Dict dict);
}
......@@ -3,10 +3,18 @@ package net.lesscoding.handmade.service;
import com.baomidou.mybatisplus.extension.service.IService;
import net.lesscoding.handmade.entity.Dict;
import java.util.List;
/**
* @author eleven
* @date 2023/6/28 19:42
* @apiNote
*/
public interface DictService extends IService<Dict> {
/**
* 获取数据
* @param dict
* @return
*/
List<Dict> dictList(Dict dict);
}
......@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.lesscoding.handmade.entity.Dict;
import net.lesscoding.handmade.mapper.DictMapper;
import net.lesscoding.handmade.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author eleven
* @date 2023/6/28 19:46
......@@ -13,4 +16,12 @@ import org.springframework.stereotype.Service;
*/
@Service
public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements DictService {
@Autowired
private DictMapper dictMapper;
@Override
public List<Dict> dictList(Dict dict) {
return dictMapper.getDictList(dict);
}
}
package net.lesscoding.handmade.utils;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import java.sql.Timestamp;
import java.time.*;
import java.util.Date;
......@@ -68,8 +71,12 @@ public class DateUtil {
}
}
public static void main(String[] args) {
public static void main(String[] args) throws InterruptedException {
LocalTime time = localDateTime2Other(LocalDateTime.now(), LocalTime.class);
System.out.println(time);
for (int i = 0; i < 100; i++) {
Thread.sleep(RandomUtil.randomInt(10));
System.out.println(IdUtil.getSnowflakeNextId());
}
}
}
<?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="net.lesscoding.handmade.mapper.DictMapper">
<resultMap id="baseMap" type="net.lesscoding.handmade.entity.Dict">
<id column="id" property="id" />
<result column="dict_type" property="dictType" />
<result column="sort" property="sort" />
<result column="dict_code" property="dictCode" />
<result column="dict_value" property="dictValue" />
<result column="description" property="description" />
<result column="create_time" property="createTime" />
<result column="create_by" property="createBy" />
<result column="update_time" property="updateTime" />
<result column="update_by" property="updateBy" />
<result column="del_flag" property="delFlag" />
</resultMap>
<select id="getDictList" resultMap="baseMap">
select id,
dict_type,
sort,
dict_code,
dict_value,
description,
create_by,
create_time,
update_by,
update_time,
del_flag
from sys_dict
<where>
del_flag = false
<if test="dictType != null and dictType != ''">
and dict_type = #{dictType}
</if>
<if test="dictCode != null and dictCode != ''">
and dict_code = #{dictCode}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册