Просмотр исходного кода

add auto model_no function, update getUserModel function

Danj0rr 1 год назад
Родитель
Сommit
5937dd58eb

+ 2 - 1
src/main/java/com/kexun/controller/FileUploadController.java

@@ -107,7 +107,7 @@ public class FileUploadController {
     @PostMapping("/fileupload")
     @ResponseBody
     public Result upload2(@RequestParam Integer index, @RequestParam MultipartFile chunk, @RequestParam String name, @RequestParam Integer chunksLength, @RequestParam String uid
-            , @RequestParam String model_name, @RequestParam String model_type, @RequestParam String output_list, SysUser sysUser
+            , @RequestParam String model_name, @RequestParam String model_type,@RequestParam String model_no, @RequestParam String output_list, SysUser sysUser
     ) throws IOException {
         int type = Integer.parseInt(model_type);
         if (type == 1 || type == 2) {
@@ -150,6 +150,7 @@ public class FileUploadController {
             new_modelEntity.setCreateBy(sysUser.getId());
             new_modelEntity.setModelName(model_name);
             new_modelEntity.setModelType(type);
+            new_modelEntity.setModelNo(model_no);
             new_modelEntity.setStatus("暂停使用");
 //            new_model.setOtherData(name);
 //            new_model.setOutputList(output_list);

+ 13 - 6
src/main/java/com/kexun/controller/ModelController.java

@@ -49,6 +49,16 @@ public class ModelController {
 
     private JsonFile jsonFile = new JsonFile();
 
+    @GetMapping("getModelNo")
+    public Result getModelNo(){
+        JSONObject resJson = new JSONObject();
+        String model_no=userModelService.getModelNo();
+
+        System.out.println(model_no);
+
+        resJson.put("model_no", model_no);
+        return Result.success("ok", resJson);
+    }
     //给模型复核员提供模型复核
     @GetMapping("listUser")
     public Result listUser(SysUser sysUser) {
@@ -444,13 +454,10 @@ public class ModelController {
     @GetMapping("getUserModel")
     public Result getUserModel(SysUser sysUser) {
         JSONObject resJson = new JSONObject();
-        List<ModelEntity> model_Entity_list = userModelService.findByUserName(sysUser.getUserName());
-//        System.out.println(model_list.get(0).getId());
-        resJson.put("modelData", model_Entity_list);
-
+        List<ModelEntity> model_list = userModelService.findAll();
+//        List<ModelEntity> model_Entity_list = userModelService.findByUserName(sysUser.getUserName());
+        resJson.put("modelData", model_list);
         return Result.success("ok", resJson);
-
-
     }
 
     //    获取当前模型

+ 3 - 0
src/main/java/com/kexun/entity/ModelEntity.java

@@ -44,6 +44,9 @@ public class ModelEntity extends BaseEntity implements Serializable {
     @TableField(value = "file_path")
     private String filePath;
 
+//    @TableField(value = "create_by")
+//    private String userName;
+
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 

+ 2 - 0
src/main/java/com/kexun/mapper/UserModelMapper.java

@@ -6,4 +6,6 @@ import org.springframework.data.repository.query.Param;
 
 public interface UserModelMapper extends BaseMapper<ModelEntity> {
     void changeModelNameQuery(@Param("modelName") String modelName, @Param("modelNo") long modelNo);
+
+    String getModelNo();
 }

+ 3 - 0
src/main/java/com/kexun/service/UserModelService.java

@@ -7,6 +7,7 @@ import java.util.List;
 
 public interface UserModelService extends IService<ModelEntity> {
 
+    List<ModelEntity> findAll();
     List<ModelEntity> findByUserName(String user_name);
     ModelEntity findByModelName(String model_name);
     ModelEntity findByUserAndModel(String user_name, String model_name);
@@ -14,4 +15,6 @@ public interface UserModelService extends IService<ModelEntity> {
     void removeModelByID(long id);
 
     void changeModelName(String modelName,long modelNo);
+
+    String getModelNo();
 }

+ 27 - 1
src/main/java/com/kexun/service/impl/UserModelServiceImpl.java

@@ -2,6 +2,7 @@ package com.kexun.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.kexun.common.Model;
 import com.kexun.entity.ModelEntity;
 import com.kexun.mapper.UserModelMapper;
 import com.kexun.service.UserModelService;
@@ -15,6 +16,27 @@ public class UserModelServiceImpl extends ServiceImpl<UserModelMapper, ModelEnti
 {
     @Resource
     UserModelMapper userModelMapper;
+
+//    public String getModelNoService(String userName) {
+//        QueryWrapper<ModelEntity> wrapper = new QueryWrapper<ModelEntity>()
+//                .eq("create_by", userName)
+//                .orderByDesc("id")
+//                .last("LIMIT 1");
+//
+//        ModelEntity lastModel = modelMapper.selectOne(wrapper);
+//
+//        if (lastModel != null) {
+//            return lastModel.getModelNo();
+//        } else {
+//            return null; // or handle the case when no data is found
+//        }
+//    }
+    @Override
+    public List<ModelEntity> findAll(){
+        List<ModelEntity> model_list=list();
+        return model_list;
+    }
+
     @Override
     public List<ModelEntity> findByUserName(String user_name) {
 
@@ -24,7 +46,6 @@ public class UserModelServiceImpl extends ServiceImpl<UserModelMapper, ModelEnti
     }
 
     @Override
-
     public ModelEntity findByModelName(String model_name)
     {
         QueryWrapper<ModelEntity> wrapper=new QueryWrapper<ModelEntity>().eq("model_name",model_name);
@@ -58,4 +79,9 @@ public class UserModelServiceImpl extends ServiceImpl<UserModelMapper, ModelEnti
         userModelMapper.changeModelNameQuery(modelName,modelNo);
     }
 
+    @Override
+    public String getModelNo(){
+        return userModelMapper.getModelNo();
+    }
+
 }

+ 9 - 2
src/main/resources/mapper/UserModelMapper.xml

@@ -6,7 +6,7 @@
 
     <resultMap id="BaseResultMap" type="com.kexun.entity.ModelEntity">
         <id property="id" column="id" jdbcType="BIGINT"/>
-        <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
+        <result property="createBy" column="create_by" jdbcType="BIGINT"/>
         <result property="modelName" column="model_name" jdbcType="VARCHAR"/>
         <!--        <result property="fieldCombine" column="field_combine" jdbcType="VARCHAR"/>-->
         <result property="modelNo" column="model_no" jdbcType="VARCHAR"/>
@@ -18,7 +18,6 @@
         <result property="filePath" column="file_path" jdbcType="VARCHAR"/>
         <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
 
-
     </resultMap>
 
     <sql id="Base_Column_List">
@@ -31,4 +30,12 @@
         SET model.model_name=#{modelName}
         WHERE model.model_no=#{modelNo}
     </select>
+
+    <resultMap id="modelNoMap" type="java.lang.String">
+        <id property="modelNo" column="model_no"/>
+    </resultMap>
+
+    <select id="getModelNo" resultMap="modelNoMap">
+        SELECT model_no FROM model ORDER BY model_no DESC LIMIT 1
+    </select>
 </mapper>