diff --git a/src/main/java/com/sztzjy/marketing/controller/stu/StuDigitalMarketingModelController.java b/src/main/java/com/sztzjy/marketing/controller/stu/StuDigitalMarketingModelController.java index 22a963f..a14a448 100644 --- a/src/main/java/com/sztzjy/marketing/controller/stu/StuDigitalMarketingModelController.java +++ b/src/main/java/com/sztzjy/marketing/controller/stu/StuDigitalMarketingModelController.java @@ -2,15 +2,19 @@ package com.sztzjy.marketing.controller.stu; import com.sztzjy.marketing.annotation.AnonymousAccess; import com.sztzjy.marketing.config.exception.handler.DigitalEconomyxception; +import com.sztzjy.marketing.entity.StuSpendingLevel; import com.sztzjy.marketing.entity.StuTrainingOperateStepExample; import com.sztzjy.marketing.entity.StuTrainingOperateStepWithBLOBs; import com.sztzjy.marketing.entity.dto.*; +import com.sztzjy.marketing.mapper.StuSpendingLevelMapper; import com.sztzjy.marketing.service.StuDigitalMarketingModelService; +import com.sztzjy.marketing.util.DataConverter; import com.sztzjy.marketing.util.ResultEntity; import com.sztzjy.marketing.util.algorithm.Apriori; import com.sztzjy.marketing.util.algorithm.KMeans; import com.sztzjy.marketing.util.algorithm.LinearRegression; import com.sztzjy.marketing.util.algorithm.LogisticRegression; +import com.sztzjy.marketing.util.excel.ImportExcelUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -43,6 +47,8 @@ public class StuDigitalMarketingModelController { @Resource StuDigitalMarketingModelService modelService; + @Resource + StuSpendingLevelMapper stuSpendingLevelMapper; @ApiOperation("选择指标--下拉框") @PostMapping("/dropdownBox") @@ -65,11 +71,9 @@ public class StuDigitalMarketingModelController { @ApiOperation("选择指标--分析数据展示") @PostMapping("/viewAnalyzeData") @AnonymousAccess - public ResultEntity viewAnalyzeData(@ApiParam("用户ID") String userId, - @ApiParam("表格名") String tableName, - @ApiParam("指标列表") @RequestParam List<String> fieldList) { + public ResultEntity viewAnalyzeData(@RequestBody AnalyzeDataDTO analyzeDataDTO) { - return modelService.viewAnalyzeData(userId,tableName,fieldList); + return modelService.viewAnalyzeData(analyzeDataDTO); } @@ -91,7 +95,7 @@ public class StuDigitalMarketingModelController { @AnonymousAccess public ResultEntity descriptiveStatistics(@ApiParam("数据集、需要计算的方式、用户ID")@RequestBody StatisticsDTO statisticsDTO) { - Map<String, List<Double>> map = statisticsDTO.getMap(); + Map<String,List<Double>> map = statisticsDTO.getMap(); List<String> statistic = statisticsDTO.getStatistic(); String userId = statisticsDTO.getUserId(); @@ -102,17 +106,13 @@ public class StuDigitalMarketingModelController { @ApiOperation("聚类分析--散点图") @PostMapping("/clusterScatterPlot") @AnonymousAccess - public ResultEntity clusterScatterPlot(@ApiParam("簇数") Integer k, - @ApiParam("最大迭代次数") Integer t, - @ApiParam("最大迭代次数") String userId, - @RequestParam(required = false) @RequestPart MultipartFile file) { + public ResultEntity clusterScatterPlot(@RequestBody ClusterScatterPlotDTO clusterScatterPlotDTO) { -// //验证文件类型 -// if (!file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")).equals(".xls") && !file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")).equals(".xlsx")) { -// return new ResultEntity(HttpStatus.ACCEPTED, "文件类型有误!请上传Excel文件"); -// } + Integer t = clusterScatterPlotDTO.getT(); + Integer k = clusterScatterPlotDTO.getK(); + List<Map<String, Object>> deduplicatedDataList = clusterScatterPlotDTO.getDeduplicatedDataList(); - List<KMeans.Point> irisData = readIrisData(file); + List<KMeans.Point> irisData = readIrisData(deduplicatedDataList); //获取数据集 KMeans kMeans = new KMeans(k, t, irisData); @@ -233,4 +233,56 @@ public class StuDigitalMarketingModelController { return modelService.emotionalAnalysis(userId,modelType,content); } + + @ApiOperation("批量导入") + @PostMapping("/batchImport") + @AnonymousAccess + public ResultEntity batchImport(@RequestPart MultipartFile file) { + + //验证文件类型 + if (!file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")).equals(".xls") && !file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")).equals(".xlsx")) { + return new ResultEntity<>(HttpStatus.ACCEPTED, "文件类型有误!请上传Excel文件"); + } + + + + try { + List<StuSpendingLevel> stuSpendingLevels=new ArrayList<>(); + + //获取数据 + List<List<Object>> listByExcel = ImportExcelUtil.getListByExcel(file.getInputStream(), file.getOriginalFilename()); + //封装数据 + for (int i = 0; i < listByExcel.size(); i++) { + List<Object> list = listByExcel.get(i); + if (list.get(0) == "" || ("序号").equals(list.get(0))) { + continue; + } + + + + StuSpendingLevel stuSpendingLevel=new StuSpendingLevel(); + stuSpendingLevel.setId(Integer.valueOf((String) list.get(0))); + stuSpendingLevel.setGender(Integer.valueOf((String) list.get(0))); + stuSpendingLevel.setAge(Integer.valueOf((String) list.get(0))); + stuSpendingLevel.setAnnualIncome(Integer.valueOf((String) list.get(0))); + stuSpendingLevel.setSpendingScore(Integer.valueOf((String) list.get(0))); + + + + stuSpendingLevels.add(stuSpendingLevel); + } + stuSpendingLevelMapper.addList(stuSpendingLevels); + + + } catch (Exception e) { + e.printStackTrace(); + }finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + return new ResultEntity(HttpStatus.OK,"成功"); + } } diff --git a/src/main/java/com/sztzjy/marketing/entity/StuSpendingLevel.java b/src/main/java/com/sztzjy/marketing/entity/StuSpendingLevel.java new file mode 100644 index 0000000..784a73e --- /dev/null +++ b/src/main/java/com/sztzjy/marketing/entity/StuSpendingLevel.java @@ -0,0 +1,64 @@ +package com.sztzjy.marketing.entity; + +import io.swagger.annotations.ApiModelProperty; +/** + * + * @author whb + * stu_spending_level + */ +public class StuSpendingLevel { + @ApiModelProperty("ID") + private Integer id; + + @ApiModelProperty("性别(1、男 2、女)") + private Integer gender; + + @ApiModelProperty("年龄") + private Integer age; + + @ApiModelProperty("年收入(万)") + private Integer annualIncome; + + @ApiModelProperty("消费水平(1-100)") + private Integer spendingScore; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getGender() { + return gender; + } + + public void setGender(Integer gender) { + this.gender = gender; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public Integer getAnnualIncome() { + return annualIncome; + } + + public void setAnnualIncome(Integer annualIncome) { + this.annualIncome = annualIncome; + } + + public Integer getSpendingScore() { + return spendingScore; + } + + public void setSpendingScore(Integer spendingScore) { + this.spendingScore = spendingScore; + } +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/marketing/entity/StuSpendingLevelExample.java b/src/main/java/com/sztzjy/marketing/entity/StuSpendingLevelExample.java new file mode 100644 index 0000000..2776b29 --- /dev/null +++ b/src/main/java/com/sztzjy/marketing/entity/StuSpendingLevelExample.java @@ -0,0 +1,499 @@ +package com.sztzjy.marketing.entity; + +import java.util.ArrayList; +import java.util.List; + +public class StuSpendingLevelExample { + protected String orderByClause; + + protected boolean distinct; + + protected List<Criteria> oredCriteria; + + public StuSpendingLevelExample() { + oredCriteria = new ArrayList<>(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List<Criteria> getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List<Criterion> criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList<>(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List<Criterion> getAllCriteria() { + return criteria; + } + + public List<Criterion> getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Integer value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Integer value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Integer value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Integer value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Integer value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Integer value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List<Integer> values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List<Integer> values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Integer value1, Integer value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Integer value1, Integer value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andGenderIsNull() { + addCriterion("gender is null"); + return (Criteria) this; + } + + public Criteria andGenderIsNotNull() { + addCriterion("gender is not null"); + return (Criteria) this; + } + + public Criteria andGenderEqualTo(Integer value) { + addCriterion("gender =", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderNotEqualTo(Integer value) { + addCriterion("gender <>", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderGreaterThan(Integer value) { + addCriterion("gender >", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderGreaterThanOrEqualTo(Integer value) { + addCriterion("gender >=", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderLessThan(Integer value) { + addCriterion("gender <", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderLessThanOrEqualTo(Integer value) { + addCriterion("gender <=", value, "gender"); + return (Criteria) this; + } + + public Criteria andGenderIn(List<Integer> values) { + addCriterion("gender in", values, "gender"); + return (Criteria) this; + } + + public Criteria andGenderNotIn(List<Integer> values) { + addCriterion("gender not in", values, "gender"); + return (Criteria) this; + } + + public Criteria andGenderBetween(Integer value1, Integer value2) { + addCriterion("gender between", value1, value2, "gender"); + return (Criteria) this; + } + + public Criteria andGenderNotBetween(Integer value1, Integer value2) { + addCriterion("gender not between", value1, value2, "gender"); + return (Criteria) this; + } + + public Criteria andAgeIsNull() { + addCriterion("age is null"); + return (Criteria) this; + } + + public Criteria andAgeIsNotNull() { + addCriterion("age is not null"); + return (Criteria) this; + } + + public Criteria andAgeEqualTo(Integer value) { + addCriterion("age =", value, "age"); + return (Criteria) this; + } + + public Criteria andAgeNotEqualTo(Integer value) { + addCriterion("age <>", value, "age"); + return (Criteria) this; + } + + public Criteria andAgeGreaterThan(Integer value) { + addCriterion("age >", value, "age"); + return (Criteria) this; + } + + public Criteria andAgeGreaterThanOrEqualTo(Integer value) { + addCriterion("age >=", value, "age"); + return (Criteria) this; + } + + public Criteria andAgeLessThan(Integer value) { + addCriterion("age <", value, "age"); + return (Criteria) this; + } + + public Criteria andAgeLessThanOrEqualTo(Integer value) { + addCriterion("age <=", value, "age"); + return (Criteria) this; + } + + public Criteria andAgeIn(List<Integer> values) { + addCriterion("age in", values, "age"); + return (Criteria) this; + } + + public Criteria andAgeNotIn(List<Integer> values) { + addCriterion("age not in", values, "age"); + return (Criteria) this; + } + + public Criteria andAgeBetween(Integer value1, Integer value2) { + addCriterion("age between", value1, value2, "age"); + return (Criteria) this; + } + + public Criteria andAgeNotBetween(Integer value1, Integer value2) { + addCriterion("age not between", value1, value2, "age"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeIsNull() { + addCriterion("annual_income is null"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeIsNotNull() { + addCriterion("annual_income is not null"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeEqualTo(Integer value) { + addCriterion("annual_income =", value, "annualIncome"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeNotEqualTo(Integer value) { + addCriterion("annual_income <>", value, "annualIncome"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeGreaterThan(Integer value) { + addCriterion("annual_income >", value, "annualIncome"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeGreaterThanOrEqualTo(Integer value) { + addCriterion("annual_income >=", value, "annualIncome"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeLessThan(Integer value) { + addCriterion("annual_income <", value, "annualIncome"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeLessThanOrEqualTo(Integer value) { + addCriterion("annual_income <=", value, "annualIncome"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeIn(List<Integer> values) { + addCriterion("annual_income in", values, "annualIncome"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeNotIn(List<Integer> values) { + addCriterion("annual_income not in", values, "annualIncome"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeBetween(Integer value1, Integer value2) { + addCriterion("annual_income between", value1, value2, "annualIncome"); + return (Criteria) this; + } + + public Criteria andAnnualIncomeNotBetween(Integer value1, Integer value2) { + addCriterion("annual_income not between", value1, value2, "annualIncome"); + return (Criteria) this; + } + + public Criteria andSpendingScoreIsNull() { + addCriterion("spending_score is null"); + return (Criteria) this; + } + + public Criteria andSpendingScoreIsNotNull() { + addCriterion("spending_score is not null"); + return (Criteria) this; + } + + public Criteria andSpendingScoreEqualTo(Integer value) { + addCriterion("spending_score =", value, "spendingScore"); + return (Criteria) this; + } + + public Criteria andSpendingScoreNotEqualTo(Integer value) { + addCriterion("spending_score <>", value, "spendingScore"); + return (Criteria) this; + } + + public Criteria andSpendingScoreGreaterThan(Integer value) { + addCriterion("spending_score >", value, "spendingScore"); + return (Criteria) this; + } + + public Criteria andSpendingScoreGreaterThanOrEqualTo(Integer value) { + addCriterion("spending_score >=", value, "spendingScore"); + return (Criteria) this; + } + + public Criteria andSpendingScoreLessThan(Integer value) { + addCriterion("spending_score <", value, "spendingScore"); + return (Criteria) this; + } + + public Criteria andSpendingScoreLessThanOrEqualTo(Integer value) { + addCriterion("spending_score <=", value, "spendingScore"); + return (Criteria) this; + } + + public Criteria andSpendingScoreIn(List<Integer> values) { + addCriterion("spending_score in", values, "spendingScore"); + return (Criteria) this; + } + + public Criteria andSpendingScoreNotIn(List<Integer> values) { + addCriterion("spending_score not in", values, "spendingScore"); + return (Criteria) this; + } + + public Criteria andSpendingScoreBetween(Integer value1, Integer value2) { + addCriterion("spending_score between", value1, value2, "spendingScore"); + return (Criteria) this; + } + + public Criteria andSpendingScoreNotBetween(Integer value1, Integer value2) { + addCriterion("spending_score not between", value1, value2, "spendingScore"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List<?>) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/marketing/entity/dto/AnalyzeDataDTO.java b/src/main/java/com/sztzjy/marketing/entity/dto/AnalyzeDataDTO.java new file mode 100644 index 0000000..15cf5a8 --- /dev/null +++ b/src/main/java/com/sztzjy/marketing/entity/dto/AnalyzeDataDTO.java @@ -0,0 +1,18 @@ +package com.sztzjy.marketing.entity.dto; + +import io.swagger.annotations.ApiParam; +import lombok.Data; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @author tz + * @date 2024/8/16 15:26 + */ +@Data +public class AnalyzeDataDTO { + private String userId; + private String tableName; + private List<String> fieldList; +} diff --git a/src/main/java/com/sztzjy/marketing/entity/dto/ClusterScatterPlotDTO.java b/src/main/java/com/sztzjy/marketing/entity/dto/ClusterScatterPlotDTO.java new file mode 100644 index 0000000..afd42ce --- /dev/null +++ b/src/main/java/com/sztzjy/marketing/entity/dto/ClusterScatterPlotDTO.java @@ -0,0 +1,23 @@ +package com.sztzjy.marketing.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @author tz + * @date 2024/8/16 16:26 + */ +@Data +public class ClusterScatterPlotDTO { + @ApiModelProperty("簇数") + private Integer k; + @ApiModelProperty("最大迭代次数") + private Integer t; + @ApiModelProperty("用户ID") + private String userId; + @ApiModelProperty("数据集") + private List<Map<String, Object>> deduplicatedDataList; +} diff --git a/src/main/java/com/sztzjy/marketing/mapper/StuSelectIndicatorsMapper.java b/src/main/java/com/sztzjy/marketing/mapper/StuSelectIndicatorsMapper.java index 620d282..109ef61 100644 --- a/src/main/java/com/sztzjy/marketing/mapper/StuSelectIndicatorsMapper.java +++ b/src/main/java/com/sztzjy/marketing/mapper/StuSelectIndicatorsMapper.java @@ -19,7 +19,7 @@ public interface StuSelectIndicatorsMapper { List<String> getYHDLHYB(); - @Select("select COLUMN_NAME from information_schema.COLUMNS where table_name = 'stu_user_consumption_ability'") + @Select("select COLUMN_NAME from information_schema.COLUMNS where table_name = 'stu_spending_level'") List<String> getYHXFNLB(); @Select("select COLUMN_NAME from information_schema.COLUMNS where table_name = 'stu_user_behavior'") diff --git a/src/main/java/com/sztzjy/marketing/mapper/StuSpendingLevelMapper.java b/src/main/java/com/sztzjy/marketing/mapper/StuSpendingLevelMapper.java new file mode 100644 index 0000000..2bc0659 --- /dev/null +++ b/src/main/java/com/sztzjy/marketing/mapper/StuSpendingLevelMapper.java @@ -0,0 +1,35 @@ +package com.sztzjy.marketing.mapper; + +import com.sztzjy.marketing.entity.StuSpendingLevel; +import com.sztzjy.marketing.entity.StuSpendingLevelExample; +import java.util.List; + +import com.sztzjy.marketing.util.ResultEntity; +import org.apache.ibatis.annotations.Param; + +public interface StuSpendingLevelMapper { + long countByExample(StuSpendingLevelExample example); + + int deleteByExample(StuSpendingLevelExample example); + + int deleteByPrimaryKey(Integer id); + + int insert(StuSpendingLevel record); + + int insertSelective(StuSpendingLevel record); + + List<StuSpendingLevel> selectByExample(StuSpendingLevelExample example); + + StuSpendingLevel selectByPrimaryKey(Integer id); + + int updateByExampleSelective(@Param("record") StuSpendingLevel record, @Param("example") StuSpendingLevelExample example); + + int updateByExample(@Param("record") StuSpendingLevel record, @Param("example") StuSpendingLevelExample example); + + int updateByPrimaryKeySelective(StuSpendingLevel record); + + int updateByPrimaryKey(StuSpendingLevel record); + + void addList(@Param("stuSpendingLevels")List<StuSpendingLevel> stuSpendingLevels); + +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/marketing/mapper/StuTableNameMapper.java b/src/main/java/com/sztzjy/marketing/mapper/StuTableNameMapper.java index 6782456..3a82a34 100644 --- a/src/main/java/com/sztzjy/marketing/mapper/StuTableNameMapper.java +++ b/src/main/java/com/sztzjy/marketing/mapper/StuTableNameMapper.java @@ -33,5 +33,5 @@ public interface StuTableNameMapper { List<String> getTableName(String userId); - List<Map<String,Object>> selectByFields(List<String> fieldList, String table); + List<Map<String,Object>> selectByFields(@Param("fieldList")List<String> fieldList, String table); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/marketing/mapper/StuUserAttributeMapper.java b/src/main/java/com/sztzjy/marketing/mapper/StuUserAttributeMapper.java index 6ef0d9a..07f298e 100644 --- a/src/main/java/com/sztzjy/marketing/mapper/StuUserAttributeMapper.java +++ b/src/main/java/com/sztzjy/marketing/mapper/StuUserAttributeMapper.java @@ -3,6 +3,8 @@ package com.sztzjy.marketing.mapper; import com.sztzjy.marketing.entity.StuUserAttribute; import com.sztzjy.marketing.entity.StuUserAttributeExample; import java.util.List; +import java.util.Map; + import org.apache.ibatis.annotations.Param; public interface StuUserAttributeMapper { @@ -27,4 +29,6 @@ public interface StuUserAttributeMapper { int updateByPrimaryKeySelective(StuUserAttribute record); int updateByPrimaryKey(StuUserAttribute record); + + List<Map<String,StuUserAttribute>> selectByFields(List<String> fieldList, String table); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/marketing/mapper/StuUserBehaviorMapper.java b/src/main/java/com/sztzjy/marketing/mapper/StuUserBehaviorMapper.java index f0dba2e..1568b0a 100644 --- a/src/main/java/com/sztzjy/marketing/mapper/StuUserBehaviorMapper.java +++ b/src/main/java/com/sztzjy/marketing/mapper/StuUserBehaviorMapper.java @@ -29,4 +29,6 @@ public interface StuUserBehaviorMapper { int updateByPrimaryKeySelective(StuUserBehavior record); int updateByPrimaryKey(StuUserBehavior record); + + List<StuUserBehavior> selectByFields(List<String> fieldList, String table); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/marketing/mapper/StuUserConsumptionAbilityMapper.java b/src/main/java/com/sztzjy/marketing/mapper/StuUserConsumptionAbilityMapper.java index 95c2c70..9b54c38 100644 --- a/src/main/java/com/sztzjy/marketing/mapper/StuUserConsumptionAbilityMapper.java +++ b/src/main/java/com/sztzjy/marketing/mapper/StuUserConsumptionAbilityMapper.java @@ -27,4 +27,6 @@ public interface StuUserConsumptionAbilityMapper { int updateByPrimaryKeySelective(StuUserConsumptionAbility record); int updateByPrimaryKey(StuUserConsumptionAbility record); + + List<StuUserConsumptionAbility> selectByFields(List<String> fieldList, String table); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/marketing/mapper/StuUserLoginActiveMapper.java b/src/main/java/com/sztzjy/marketing/mapper/StuUserLoginActiveMapper.java index 76b0ecc..61fcd79 100644 --- a/src/main/java/com/sztzjy/marketing/mapper/StuUserLoginActiveMapper.java +++ b/src/main/java/com/sztzjy/marketing/mapper/StuUserLoginActiveMapper.java @@ -27,4 +27,6 @@ public interface StuUserLoginActiveMapper { int updateByPrimaryKeySelective(StuUserLoginActive record); int updateByPrimaryKey(StuUserLoginActive record); + + List<StuUserLoginActive> selectByFields(List<String> fieldList, String table); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/marketing/service/StuDigitalMarketingModelService.java b/src/main/java/com/sztzjy/marketing/service/StuDigitalMarketingModelService.java index e387be9..8a5357b 100644 --- a/src/main/java/com/sztzjy/marketing/service/StuDigitalMarketingModelService.java +++ b/src/main/java/com/sztzjy/marketing/service/StuDigitalMarketingModelService.java @@ -1,5 +1,6 @@ package com.sztzjy.marketing.service; +import com.sztzjy.marketing.entity.dto.AnalyzeDataDTO; import com.sztzjy.marketing.util.ResultEntity; import org.springframework.stereotype.Service; @@ -21,7 +22,7 @@ public interface StuDigitalMarketingModelService { List<String> viewMetrics(String userId, String tableName); - ResultEntity viewAnalyzeData(String userId, String tableName, List<String> fieldList); + ResultEntity viewAnalyzeData(AnalyzeDataDTO analyzeDataDTO); ResultEntity dataPreprocessing(String userId, String method, List<Map<String, Object>> mapList); diff --git a/src/main/java/com/sztzjy/marketing/service/impl/StuDigitalMarketingModelServiceImpl.java b/src/main/java/com/sztzjy/marketing/service/impl/StuDigitalMarketingModelServiceImpl.java index 731e8c2..28ed716 100644 --- a/src/main/java/com/sztzjy/marketing/service/impl/StuDigitalMarketingModelServiceImpl.java +++ b/src/main/java/com/sztzjy/marketing/service/impl/StuDigitalMarketingModelServiceImpl.java @@ -5,11 +5,11 @@ import com.hankcs.hanlp.HanLP; import com.hankcs.hanlp.seg.common.Term; import com.sztzjy.marketing.config.Constant; import com.sztzjy.marketing.entity.*; +import com.sztzjy.marketing.entity.dto.AnalyzeDataDTO; import com.sztzjy.marketing.entity.dto.DescriptiveStatistics; import com.sztzjy.marketing.entity.dto.DescriptiveStatisticsDTO; import com.sztzjy.marketing.entity.dto.WordFrequencyDTO; -import com.sztzjy.marketing.mapper.StuSelectIndicatorsMapper; -import com.sztzjy.marketing.mapper.StuTableNameMapper; +import com.sztzjy.marketing.mapper.*; import com.sztzjy.marketing.service.StuDigitalMarketingModelService; import com.sztzjy.marketing.util.ResultEntity; import com.sztzjy.marketing.util.algorithm.DescriptiveStatisticsUtil; @@ -19,7 +19,10 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.IOException; +import java.time.Instant; import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.*; import static com.sztzjy.marketing.util.algorithm.BaiDuZhiNengYun.getAccessToken; @@ -39,9 +42,15 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM @Resource StuSelectIndicatorsMapper indicatorsMapper; - @Resource - StuTableNameMapper tableNameMapper; + StuUserAttributeMapper userAttributeMapper; + @Resource + StuUserLoginActiveMapper userLoginActiveMapper; + @Resource + StuUserConsumptionAbilityMapper userConsumptionAbilityMapper; + @Resource + StuUserBehaviorMapper userBehaviorMapper; + @Override public List<String> dropdownBox(String userId) { @@ -243,10 +252,14 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM List<String> list=new ArrayList<>(); if(tableName.equals(Constant.YHSXB)){ - list=indicatorsMapper.getYHSXB(); +// list=indicatorsMapper.getYHSXB(); + list.add("id"); + list.add("role_gender"); + list.add("role_age"); } if(tableName.equals(Constant.YHDLHYB)){ list=indicatorsMapper.getYHDLHYB(); + } if(tableName.equals(Constant.YHXFNLB)){ list=indicatorsMapper.getYHXFNLB(); @@ -258,41 +271,46 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM } @Override - public ResultEntity viewAnalyzeData(String userId, String tableName, List<String> fieldList) { + public ResultEntity viewAnalyzeData(AnalyzeDataDTO analyzeDataDTO) { String table=null; - if(tableName.equals(Constant.YHSXB)){ //查询用户属性表 + if(analyzeDataDTO.getTableName().equals(Constant.YHSXB)){ //查询用户属性表 table="stu_user_attribute"; } - if(tableName.equals(Constant.YHDLHYB)){ //查询用户登录活跃表 + if(analyzeDataDTO.getTableName().equals(Constant.YHDLHYB)){ //查询用户登录活跃表 table="stu_user_login_active"; } - if(tableName.equals(Constant.YHXFNLB)){ //查询用户消费能力表 - table="stu_user_consumption_ability"; + if(analyzeDataDTO.getTableName().equals(Constant.YHXFNLB)){ //查询用户消费能力表 + table="stu_spending_level"; } - if(tableName.equals(Constant.YHPLB) || tableName.equals(Constant.YHXWB)){ //查询用户评论或行为表 + if(analyzeDataDTO.getTableName().equals(Constant.YHPLB) || analyzeDataDTO.getTableName().equals(Constant.YHXWB)){ //查询用户评论或行为表 table="stu_user_behavior"; + } + List<String> fieldList = analyzeDataDTO.getFieldList(); - List<Map<String,Object>> attributes = tableNameMapper.selectByFields(fieldList,table); + List<Map<String,Object>> attributes = stuTableNameMapper.selectByFields(fieldList,table); - //将日期类型转为string返回 + + //将日期类型转为时间戳返回 for (Map<String, Object> row : attributes) { for (Map.Entry<String, Object> entry : row.entrySet()) { if (entry.getValue() instanceof LocalDateTime) { - entry.setValue(entry.getValue().toString()); + LocalDateTime localDateTime = (LocalDateTime) entry.getValue(); + ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.systemDefault()); + Instant instant = zonedDateTime.toInstant(); + entry.setValue(instant.toEpochMilli()); } } } - return new ResultEntity(HttpStatus.OK,attributes); } @@ -312,7 +330,7 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM //判断缺失值处理方式 - if(method.equals("剔除数据")){ + if(method.equals("缺失值处理--剔除数据")){ deduplicatedDataList.removeIf(record -> record.containsValue(null)); @@ -322,7 +340,7 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM - if(method.equals("均值代替")){ + if(method.equals("缺失值处理--均值代替")){ // // 均值代替处理 // for (Map<String, Object> record : deduplicatedDataList) { diff --git a/src/main/java/com/sztzjy/marketing/util/DataConverter.java b/src/main/java/com/sztzjy/marketing/util/DataConverter.java new file mode 100644 index 0000000..c21cf65 --- /dev/null +++ b/src/main/java/com/sztzjy/marketing/util/DataConverter.java @@ -0,0 +1,29 @@ +package com.sztzjy.marketing.util; + +import cn.hutool.http.HttpException; +import com.sztzjy.marketing.config.exception.handler.ServiceException; +import org.springframework.http.HttpStatus; + +import java.util.*; +import java.util.stream.Collectors; + +public class DataConverter { + + public static Map<String, List<Double>> convertToDouble(Map<String, List<Object>> originalMap) { + Map<String, List<Double>> convertedMap = new HashMap<>(); + for (Map.Entry<String, List<Object>> entry : originalMap.entrySet()) { + List<Double> convertedList = entry.getValue().stream() + .map(element -> { + try { + return Double.parseDouble(element.toString()); + } catch (NumberFormatException e) { + throw new ServiceException(HttpStatus.ACCEPTED,"指标选择错误"); + } + }) + .collect(Collectors.toList()); + convertedMap.put(entry.getKey(), convertedList); + } + return convertedMap; + } + +} \ No newline at end of file diff --git a/src/main/java/com/sztzjy/marketing/util/algorithm/KMeans.java b/src/main/java/com/sztzjy/marketing/util/algorithm/KMeans.java index 756a3f0..804853e 100644 --- a/src/main/java/com/sztzjy/marketing/util/algorithm/KMeans.java +++ b/src/main/java/com/sztzjy/marketing/util/algorithm/KMeans.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Random; public class KMeans { @@ -152,22 +153,20 @@ public class KMeans { // } // } - public static List<KMeans.Point> readIrisData(MultipartFile file) { + public static List<KMeans.Point> readIrisData(List<Map<String, Object>> deduplicatedDataList) { List<KMeans.Point> points = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(new InputStreamReader(file.getInputStream()))) { - String line; + for (Map<String, Object> data : deduplicatedDataList) { + // 假设每个Map都有"x"和"y"键,并且它们的值是Double类型 + // 这里没有错误处理,你可能需要添加一些来确保键存在且值可以转换为Double + Double x = (Double) data.get("x"); + Double y = (Double) data.get("y"); - // 跳过标题行 - br.readLine(); - - while ((line = br.readLine()) != null) { - String[] values = line.split(","); - double x = Double.parseDouble(values[0]); // 假设第一列是数值 - double y = Double.parseDouble(values[1]); // 假设第二列是数值 + if (x != null && y != null) { points.add(new KMeans.Point(x, y)); + } else { + // 处理缺少x或y的情况,比如记录日志或抛出异常 + System.err.println("数据中缺少x或y: " + data); } - } catch (IOException e) { - e.printStackTrace(); } return points; } diff --git a/src/main/resources/mappers/StuSpendingLevelMapper.xml b/src/main/resources/mappers/StuSpendingLevelMapper.xml new file mode 100644 index 0000000..6a3b65b --- /dev/null +++ b/src/main/resources/mappers/StuSpendingLevelMapper.xml @@ -0,0 +1,218 @@ +<?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.sztzjy.marketing.mapper.StuSpendingLevelMapper"> + <resultMap id="BaseResultMap" type="com.sztzjy.marketing.entity.StuSpendingLevel"> + <id column="id" jdbcType="INTEGER" property="id" /> + <result column="gender" jdbcType="INTEGER" property="gender" /> + <result column="age" jdbcType="INTEGER" property="age" /> + <result column="annual_income" jdbcType="INTEGER" property="annualIncome" /> + <result column="spending_score" jdbcType="INTEGER" property="spendingScore" /> + </resultMap> + <sql id="Example_Where_Clause"> + <where> + <foreach collection="oredCriteria" item="criteria" separator="or"> + <if test="criteria.valid"> + <trim prefix="(" prefixOverrides="and" suffix=")"> + <foreach collection="criteria.criteria" item="criterion"> + <choose> + <when test="criterion.noValue"> + and ${criterion.condition} + </when> + <when test="criterion.singleValue"> + and ${criterion.condition} #{criterion.value} + </when> + <when test="criterion.betweenValue"> + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + </when> + <when test="criterion.listValue"> + and ${criterion.condition} + <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> + #{listItem} + </foreach> + </when> + </choose> + </foreach> + </trim> + </if> + </foreach> + </where> + </sql> + <sql id="Update_By_Example_Where_Clause"> + <where> + <foreach collection="example.oredCriteria" item="criteria" separator="or"> + <if test="criteria.valid"> + <trim prefix="(" prefixOverrides="and" suffix=")"> + <foreach collection="criteria.criteria" item="criterion"> + <choose> + <when test="criterion.noValue"> + and ${criterion.condition} + </when> + <when test="criterion.singleValue"> + and ${criterion.condition} #{criterion.value} + </when> + <when test="criterion.betweenValue"> + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + </when> + <when test="criterion.listValue"> + and ${criterion.condition} + <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> + #{listItem} + </foreach> + </when> + </choose> + </foreach> + </trim> + </if> + </foreach> + </where> + </sql> + <sql id="Base_Column_List"> + id, gender, age, annual_income, spending_score + </sql> + <select id="selectByExample" parameterType="com.sztzjy.marketing.entity.StuSpendingLevelExample" resultMap="BaseResultMap"> + select + <if test="distinct"> + distinct + </if> + <include refid="Base_Column_List" /> + from stu_spending_level + <if test="_parameter != null"> + <include refid="Example_Where_Clause" /> + </if> + <if test="orderByClause != null"> + order by ${orderByClause} + </if> + </select> + <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> + select + <include refid="Base_Column_List" /> + from stu_spending_level + where id = #{id,jdbcType=INTEGER} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> + delete from stu_spending_level + where id = #{id,jdbcType=INTEGER} + </delete> + <delete id="deleteByExample" parameterType="com.sztzjy.marketing.entity.StuSpendingLevelExample"> + delete from stu_spending_level + <if test="_parameter != null"> + <include refid="Example_Where_Clause" /> + </if> + </delete> + <insert id="insert" parameterType="com.sztzjy.marketing.entity.StuSpendingLevel"> + insert into stu_spending_level (id, gender, age, + annual_income, spending_score) + values (#{id,jdbcType=INTEGER}, #{gender,jdbcType=INTEGER}, #{age,jdbcType=INTEGER}, + #{annualIncome,jdbcType=INTEGER}, #{spendingScore,jdbcType=INTEGER}) + </insert> + <insert id="insertSelective" parameterType="com.sztzjy.marketing.entity.StuSpendingLevel"> + insert into stu_spending_level + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="gender != null"> + gender, + </if> + <if test="age != null"> + age, + </if> + <if test="annualIncome != null"> + annual_income, + </if> + <if test="spendingScore != null"> + spending_score, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=INTEGER}, + </if> + <if test="gender != null"> + #{gender,jdbcType=INTEGER}, + </if> + <if test="age != null"> + #{age,jdbcType=INTEGER}, + </if> + <if test="annualIncome != null"> + #{annualIncome,jdbcType=INTEGER}, + </if> + <if test="spendingScore != null"> + #{spendingScore,jdbcType=INTEGER}, + </if> + </trim> + </insert> + <select id="countByExample" parameterType="com.sztzjy.marketing.entity.StuSpendingLevelExample" resultType="java.lang.Long"> + select count(*) from stu_spending_level + <if test="_parameter != null"> + <include refid="Example_Where_Clause" /> + </if> + </select> + <update id="updateByExampleSelective" parameterType="map"> + update stu_spending_level + <set> + <if test="record.id != null"> + id = #{record.id,jdbcType=INTEGER}, + </if> + <if test="record.gender != null"> + gender = #{record.gender,jdbcType=INTEGER}, + </if> + <if test="record.age != null"> + age = #{record.age,jdbcType=INTEGER}, + </if> + <if test="record.annualIncome != null"> + annual_income = #{record.annualIncome,jdbcType=INTEGER}, + </if> + <if test="record.spendingScore != null"> + spending_score = #{record.spendingScore,jdbcType=INTEGER}, + </if> + </set> + <if test="_parameter != null"> + <include refid="Update_By_Example_Where_Clause" /> + </if> + </update> + <update id="updateByExample" parameterType="map"> + update stu_spending_level + set id = #{record.id,jdbcType=INTEGER}, + gender = #{record.gender,jdbcType=INTEGER}, + age = #{record.age,jdbcType=INTEGER}, + annual_income = #{record.annualIncome,jdbcType=INTEGER}, + spending_score = #{record.spendingScore,jdbcType=INTEGER} + <if test="_parameter != null"> + <include refid="Update_By_Example_Where_Clause" /> + </if> + </update> + <update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.marketing.entity.StuSpendingLevel"> + update stu_spending_level + <set> + <if test="gender != null"> + gender = #{gender,jdbcType=INTEGER}, + </if> + <if test="age != null"> + age = #{age,jdbcType=INTEGER}, + </if> + <if test="annualIncome != null"> + annual_income = #{annualIncome,jdbcType=INTEGER}, + </if> + <if test="spendingScore != null"> + spending_score = #{spendingScore,jdbcType=INTEGER}, + </if> + </set> + where id = #{id,jdbcType=INTEGER} + </update> + <update id="updateByPrimaryKey" parameterType="com.sztzjy.marketing.entity.StuSpendingLevel"> + update stu_spending_level + set gender = #{gender,jdbcType=INTEGER}, + age = #{age,jdbcType=INTEGER}, + annual_income = #{annualIncome,jdbcType=INTEGER}, + spending_score = #{spendingScore,jdbcType=INTEGER} + where id = #{id,jdbcType=INTEGER} + </update> + <insert id="addList"> + INSERT INTO tch_start_course_name_list (id, gender, age, annual_income, spending_score) + VALUES + <foreach collection="stuSpendingLevels" item="stuSpendingLevel" separator=","> + (#{stuSpendingLevel.id}, #{stuSpendingLevel.gender}, #{stuSpendingLevel.age}, #{stuSpendingLevel.annual_income}, #{stuSpendingLevel.spending_score}) + </foreach> + </insert> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mappers/StuTableNameMapper.xml b/src/main/resources/mappers/StuTableNameMapper.xml index aeb9410..da0b640 100644 --- a/src/main/resources/mappers/StuTableNameMapper.xml +++ b/src/main/resources/mappers/StuTableNameMapper.xml @@ -214,6 +214,7 @@ <select id="getTableName" resultType="java.lang.String"> select table_name from stu_table_name where user_id=#{userId} </select> + <select id="selectByFields" resultType="java.util.Map"> SELECT <foreach collection="fieldList" item="field" separator=","> diff --git a/src/main/resources/mappers/StuUserAttributeMapper.xml b/src/main/resources/mappers/StuUserAttributeMapper.xml index b553f67..4fed9cb 100644 --- a/src/main/resources/mappers/StuUserAttributeMapper.xml +++ b/src/main/resources/mappers/StuUserAttributeMapper.xml @@ -367,4 +367,11 @@ location = #{location,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} </update> + <select id="selectByFields" resultType="java.util.Map"> + SELECT + <foreach collection="fieldList" item="field" separator=","> + ${field} + </foreach> + FROM ${table} + </select> </mapper> \ No newline at end of file diff --git a/src/main/resources/mappers/StuUserBehaviorMapper.xml b/src/main/resources/mappers/StuUserBehaviorMapper.xml index 70541be..96a6c43 100644 --- a/src/main/resources/mappers/StuUserBehaviorMapper.xml +++ b/src/main/resources/mappers/StuUserBehaviorMapper.xml @@ -235,7 +235,8 @@ <include refid="Example_Where_Clause" /> </if> </select> - <update id="updateByExampleSelective" parameterType="map"> + + <update id="updateByExampleSelective" parameterType="map"> update stu_user_behavior <set> <if test="record.id != null"> @@ -383,4 +384,11 @@ update_time = #{updateTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=INTEGER} </update> + <select id="selectByFields" resultType="com.sztzjy.marketing.entity.StuUserBehavior" resultMap="BaseResultMap"> + SELECT + <foreach collection="fieldList" item="field" separator=","> + ${field} + </foreach> + FROM ${table} + </select> </mapper> \ No newline at end of file diff --git a/src/main/resources/mappers/StuUserConsumptionAbilityMapper.xml b/src/main/resources/mappers/StuUserConsumptionAbilityMapper.xml index 5ea33f6..c9ae638 100644 --- a/src/main/resources/mappers/StuUserConsumptionAbilityMapper.xml +++ b/src/main/resources/mappers/StuUserConsumptionAbilityMapper.xml @@ -251,7 +251,8 @@ <include refid="Example_Where_Clause" /> </if> </select> - <update id="updateByExampleSelective" parameterType="map"> + + <update id="updateByExampleSelective" parameterType="map"> update stu_user_consumption_ability <set> <if test="record.id != null"> @@ -415,4 +416,11 @@ update_time = #{updateTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=INTEGER} </update> + <select id="selectByFields" resultType="com.sztzjy.marketing.entity.StuUserConsumptionAbility" resultMap="BaseResultMap"> + SELECT + <foreach collection="fieldList" item="field" separator=","> + ${field} + </foreach> + FROM ${table} + </select> </mapper> \ No newline at end of file diff --git a/src/main/resources/mappers/StuUserLoginActiveMapper.xml b/src/main/resources/mappers/StuUserLoginActiveMapper.xml index 0f6f363..6c9580f 100644 --- a/src/main/resources/mappers/StuUserLoginActiveMapper.xml +++ b/src/main/resources/mappers/StuUserLoginActiveMapper.xml @@ -228,7 +228,8 @@ <include refid="Example_Where_Clause" /> </if> </select> - <update id="updateByExampleSelective" parameterType="map"> + + <update id="updateByExampleSelective" parameterType="map"> update stu_user_login_active <set> <if test="record.id != null"> @@ -368,4 +369,11 @@ update_time = #{updateTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=INTEGER} </update> + <select id="selectByFields" resultType="com.sztzjy.marketing.entity.StuUserLoginActive" resultMap="BaseResultMap"> + SELECT + <foreach collection="fieldList" item="field" separator=","> + ${field} + </foreach> + FROM ${table} + </select> </mapper> \ No newline at end of file