diff --git a/src/main/java/cn/chjyj/szwh/bean/OperationLog.java b/src/main/java/cn/chjyj/szwh/bean/OperationLog.java new file mode 100644 index 0000000..6cf1e72 --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/bean/OperationLog.java @@ -0,0 +1,43 @@ +package cn.chjyj.szwh.bean; + +/** + * 操作日志 + */ +public class OperationLog { + private Integer id; + private String type; // 种类 + private Integer logid; //操作id + private String message; //操作记录 + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Integer getLogid() { + return logid; + } + + public void setLogid(Integer logid) { + this.logid = logid; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/main/java/cn/chjyj/szwh/controller/admin/AdminLogController.java b/src/main/java/cn/chjyj/szwh/controller/admin/AdminLogController.java new file mode 100644 index 0000000..da43a92 --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/controller/admin/AdminLogController.java @@ -0,0 +1,32 @@ +package cn.chjyj.szwh.controller.admin; + +import cn.chjyj.szwh.bean.OperationLog; +import cn.chjyj.szwh.controller.BaseController; +import cn.chjyj.szwh.service.OperationLogService; +import com.alibaba.fastjson.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** + * 日志控制器 + */ +@RestController +@RequestMapping("admin/Log") +public class AdminLogController extends BaseController { + @Autowired + private OperationLogService operationLogService; + + @PostMapping("/getLog") + public JSONObject getLog(HttpServletRequest request){ + String logid=request.getParameter("log_id"); + String type=request.getParameter("type"); + List oplist = operationLogService.getLog(type,logid); + return jsonObject; + } + +} diff --git a/src/main/java/cn/chjyj/szwh/mapper/OperationLogMapper.java b/src/main/java/cn/chjyj/szwh/mapper/OperationLogMapper.java new file mode 100644 index 0000000..e7712ea --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/mapper/OperationLogMapper.java @@ -0,0 +1,29 @@ +package cn.chjyj.szwh.mapper; + +import cn.chjyj.szwh.bean.OperationLog; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 操作日志 mapper + */ +@Component +public interface OperationLogMapper { + /** + * 检索相应的操作日志 + * @param logId + * @param type + * @return + */ + List getOperationLog(@Param("logId") String logId, + @Param("type") String type); + + /** + * 添加日志 + * @param operationLog + * @return + */ + int addLog(OperationLog operationLog); +} diff --git a/src/main/java/cn/chjyj/szwh/service/OperationLogService.java b/src/main/java/cn/chjyj/szwh/service/OperationLogService.java new file mode 100644 index 0000000..69980d1 --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/service/OperationLogService.java @@ -0,0 +1,15 @@ +package cn.chjyj.szwh.service; + +import cn.chjyj.szwh.bean.OperationLog; + +import java.util.List; + +public interface OperationLogService { + /** + * 查找日志 + * @param type + * @param logId + * @return + */ + List getLog(String type, String logId); +} diff --git a/src/main/java/cn/chjyj/szwh/service/impl/OperationLogServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/OperationLogServiceImpl.java new file mode 100644 index 0000000..0ae8027 --- /dev/null +++ b/src/main/java/cn/chjyj/szwh/service/impl/OperationLogServiceImpl.java @@ -0,0 +1,21 @@ +package cn.chjyj.szwh.service.impl; + +import cn.chjyj.szwh.bean.OperationLog; +import cn.chjyj.szwh.mapper.OperationLogMapper; +import cn.chjyj.szwh.service.OperationLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class OperationLogServiceImpl implements OperationLogService { + @Autowired + private OperationLogMapper operationLogMapper; + + @Override + public List getLog(String type, int logId) { + String slogId = String.valueOf(logId); + return operationLogMapper.getOperationLog(slogId,type); + } +} diff --git a/src/main/resources/mapper/szwh/OperationLogMapper.xml b/src/main/resources/mapper/szwh/OperationLogMapper.xml new file mode 100644 index 0000000..e2984cc --- /dev/null +++ b/src/main/resources/mapper/szwh/OperationLogMapper.xml @@ -0,0 +1,71 @@ + + + + + + id,`type`,log_id as logId,message + + operation_log + + + + + + + + + + + + + + + insert into + + (`type`,log_id,mesage) + values ( + #{type}, + #{logId}, + #{message} + ) + + + + update + + + + user_isli=#{userIsli}, + + + username=#{username}, + + + institution_code =#{institutionCode}, + + + agency_type=#{agencyType} + + + + where id=#{id}; + + + \ No newline at end of file diff --git a/src/test/java/cn/chjyj/szwh/mapper/OperationLogMapperTest.java b/src/test/java/cn/chjyj/szwh/mapper/OperationLogMapperTest.java new file mode 100644 index 0000000..41cd3ad --- /dev/null +++ b/src/test/java/cn/chjyj/szwh/mapper/OperationLogMapperTest.java @@ -0,0 +1,31 @@ +package cn.chjyj.szwh.mapper; + +import cn.chjyj.szwh.bean.OperationLog; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +@SpringBootTest +@RunWith(SpringRunner.class) +public class OperationLogMapperTest { + @Autowired + private OperationLogMapper operationLogMapper; + + @Test + public void getOperationLog() { + String type="goods"; + int logid=17; + List aoplist =operationLogMapper.getOperationLog(String.valueOf(logid),type); + System.out.println(aoplist.size()); + } + + @Test + public void addLog() { + } +} \ No newline at end of file