Bladeren bron

1.代码分支拆分回退

yuanliang 1 jaar geleden
bovenliggende
commit
45a39cbc15

+ 27 - 157
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/SysSuggestionController.java

@@ -1,43 +1,19 @@
 package com.yonge.cooleshow.admin.controller;
 
-import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.microsvc.toolkit.common.response.paging.PageInfo;
-import com.microsvc.toolkit.common.response.paging.QueryInfo;
-import com.microsvc.toolkit.common.response.template.R;
-import com.yonge.cooleshow.admin.io.request.SysSuggestionVo;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.entity.SysSuggestion;
-import com.yonge.cooleshow.biz.dal.entity.SysSuggestionType;
-import com.yonge.cooleshow.biz.dal.entity.SysUser;
-import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.queryInfo.SysSuggestionQueryInfo;
 import com.yonge.cooleshow.biz.dal.service.SysSuggestionService;
-import com.yonge.cooleshow.biz.dal.service.SysSuggestionTypeService;
-import com.yonge.cooleshow.biz.dal.service.SysUserService;
-import com.yonge.cooleshow.biz.dal.wrapper.SysSuggestionWrapper;
 import com.yonge.cooleshow.common.controller.BaseController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
 @Api(tags = "意见反馈")
 @RestController
 @RequestMapping("${app-config.url.admin:}/")
@@ -45,145 +21,39 @@ public class SysSuggestionController extends BaseController {
 
     @Autowired
     private SysSuggestionService sysSuggestionService;
-    @Resource
-    private SysUserFeignService sysUserFeignService;
-
     @Autowired
-    private SysUserService sysUserService;
-
-    @Autowired
-    private SysSuggestionTypeService sysSuggestionTypeService;
-
-    /**
-     * 查询单条
-     *
-     * @param id 详情ID
-     * @return R<SysSuggestionVo.SysSuggestion>
-     */
-    @ApiOperation(value = "详情", notes = "传入id")
-    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/detail')")
-    @GetMapping("/detail/{id}")
-    public R<SysSuggestionWrapper.SysSuggestion> detail(@PathVariable("id") Long id) {
+    private SysUserFeignService sysUserFeignService;
 
-        // 建议详情
-        SysSuggestion wrapper = sysSuggestionService.detail(id);
-        SysSuggestionWrapper.SysSuggestion suggestion =
-                SysSuggestionWrapper.SysSuggestion.from(JSON.toJSONString(wrapper));
-        if (wrapper != null && wrapper.getSuggestionTypeId() != null) {
-            SysSuggestionType suggestionType = sysSuggestionTypeService.getById(wrapper.getSuggestionTypeId());
-            if (suggestionType != null) {
-                suggestion.setSuggestionTypeName(suggestionType.getName());
-            }
-            com.yonge.cooleshow.auth.api.entity.SysUser createUser = sysUserService.getByUserId(wrapper.getUserId());
-            String clientType = wrapper.getClientType();
-            if (ClientEnum.STUDENT.getCode().equals(clientType) || ClientEnum.TENANT_STUDENT.getCode().equals(clientType)) {
-                suggestion.setNickname(createUser.getUsername());
-            } else {
-                suggestion.setNickname(createUser.getRealName());
-            }
-            Long handleBy = wrapper.getHandleBy();
-            if (handleBy != null) {
-                com.yonge.cooleshow.auth.api.entity.SysUser sysUser = sysUserService.getByUserId(handleBy);
-                suggestion.setHandleName(sysUser.getUsername());
-            }
+    @ApiOperation(value = "新增")
+    @RequestMapping("sysSuggestion/add")
+    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/add')")
+    public Object add(SysSuggestion sysSuggestion) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
         }
-        return R.from(suggestion);
-    }
-
-
-    /**
-     * 查询分页
-     *
-     * @param query SysSuggestionWrapper.SysSuggestionQuery
-     * @return R<PageInfo < SysSuggestionWrapper.SysSuggestion>>
-     */
-    @ApiOperation(value = "查询分页")
-    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/queryPage')")
-    @PostMapping("/queryPage")
-    public R<PageInfo<SysSuggestionWrapper.SysSuggestion>> page(@RequestBody SysSuggestionWrapper.SysSuggestionQuery query) {
-
-        IPage<SysSuggestionWrapper.SysSuggestion> pages = sysSuggestionService.selectPage(QueryInfo.getPage(query), query);
-
-        List<SysSuggestionWrapper.SysSuggestion> records = pages.getRecords();
-
-        if (CollectionUtils.isNotEmpty(records)) {
-            List<Long> handlerList = records.stream().map(SysSuggestionWrapper.SysSuggestion::getHandleBy).filter(Objects::nonNull).distinct().collect(Collectors.toList());
-            Map<Long, SysUser> mapByIds = new HashMap<>();
-            if (CollectionUtils.isNotEmpty(handlerList)) {
-                mapByIds.putAll(sysUserService.getMapByIds(handlerList));
-            }
-            for (SysSuggestionWrapper.SysSuggestion item : records) {
-                Long handleBy = item.getHandleBy();
-                if (handleBy != null && mapByIds.containsKey(handleBy)) {
-                    item.setHandleName(mapByIds.getOrDefault(handleBy, new SysUser()).getUsername());
-                }
-            }
+        sysSuggestion.setUserId(sysUser.getId().longValue());
+        sysSuggestion.setClientType("TEACHER");
+        if(StringUtils.isEmpty(sysSuggestion.getMobileNo())){
+            sysSuggestion.setMobileNo(sysUser.getPhone());
         }
-        return R.from(QueryInfo.pageInfo(pages, records));
-    }
-
-    /**
-     * 新增
-     *
-     * @param suggestion SysSuggestionVo.SysSuggestion
-     * @return R<Boolean>
-     */
-    @ApiOperation(value = "新增", notes = "传入sysSuggestion")
-    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/page')")
-    @PostMapping("/add")
-    public R<Boolean> add(@Validated @RequestBody SysSuggestionVo.SysSuggestion suggestion,
-                          @RequestHeader(name = "user-agent") String userAgent) {
-        com.yonge.cooleshow.auth.api.entity.SysUser sysUser = sysUserFeignService.queryUserInfo();
-        suggestion.setUserId(sysUser.getId());
-        suggestion.setClientType(sysUser.getUserType());
-        suggestion.setUserAgent(userAgent);
-
-        return R.from(sysSuggestionService.save(JSON.parseObject(suggestion.jsonString(), SysSuggestion.class)));
+        sysSuggestionService.insert(sysSuggestion);
+        return succeed();
     }
 
-    /**
-     * 修改
-     *
-     * @param suggestion SysSuggestionVo.SysSuggestion
-     * @return R<Boolean>
-     */
-    @ApiOperation(value = "修改", notes = "传入sysSuggestion")
-    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/update')")
-//    @PostMapping("/update")
-    public R<Boolean> update(@Validated @RequestBody SysSuggestionVo.SysSuggestion suggestion) {
-        return R.from(sysSuggestionService.update(JSON.parseObject(suggestion.jsonString(), SysSuggestionWrapper.SysSuggestion.class)));
-    }
-
-    /**
-     * 删除
-     *
-     * @param id 详情ID
-     * @return R<Boolean>
-     */
-    @ApiOperation(value = "删除", notes = "传入id")
+    @ApiOperation(value = "删除")
+    @RequestMapping("sysSuggestion/del")
     @PreAuthorize("@pcs.hasPermissions('sysSuggestion/del')")
-//    @PostMapping("/del")
-    public R<Boolean> remove(@RequestParam Long id) {
-        return R.from(sysSuggestionService.removeById(id));
+    public Object del(Long id) {
+        sysSuggestionService.delete(id);
+        return succeed();
     }
 
-    @ApiOperation(value = "修改")
-    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/handleSuggestion')")
-    @PostMapping("/handleSuggestion")
-    public R<Boolean> handleSuggestion(@Validated @RequestBody SysSuggestionWrapper.HandleSuggestion handleSuggestion) {
-        com.yonge.cooleshow.auth.api.entity.SysUser sysUser = sysUserFeignService.queryUserInfo();
-        handleSuggestion.setHandleBy(sysUser.getId());
-        return R.from(sysSuggestionService.handleSuggestion(handleSuggestion));
-    }
-
-    @ApiOperation(value = "查询未处理的建议数量")
-    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/queryUnHandleNum')")
-    @GetMapping("/queryUnHandleNum")
-    public R<Integer> queryUnHandleNum() {
-        Integer count = sysSuggestionService.lambdaQuery()
-                .eq(SysSuggestion::getHandleStatus, false)
-                .count();
-        return R.from(count);
+    @ApiOperation(value = "分页查询")
+    @RequestMapping("sysSuggestion/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/queryPage')")
+    public Object queryPage(SysSuggestionQueryInfo queryInfo) {
+        return succeed(sysSuggestionService.queryPage(queryInfo));
     }
 
 }

+ 1 - 1
cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/SysSuggestionController.java

@@ -46,7 +46,7 @@ public class SysSuggestionController extends BaseController {
             sysSuggestion.setClientType(ClientEnum.TENANT_STUDENT.getCode());
         }
 
-        sysSuggestionService.save(sysSuggestion);
+        sysSuggestionService.insert(sysSuggestion);
         return succeed();
     }
 

+ 1 - 1
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/SysSuggestionController.java

@@ -34,7 +34,7 @@ public class SysSuggestionController extends BaseController {
         if(StringUtils.isEmpty(sysSuggestion.getMobileNo())){
             sysSuggestion.setMobileNo(sysUser.getPhone());
         }
-        sysSuggestionService.save(sysSuggestion);
+        sysSuggestionService.insert(sysSuggestion);
         return succeed();
     }
 

+ 36 - 36
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/SysSuggestionController.java

@@ -20,41 +20,41 @@ import com.yonge.cooleshow.common.controller.BaseController;
 @RestController
 public class SysSuggestionController extends BaseController {
 
-//    @Autowired
-//    private SysSuggestionService sysSuggestionService;
-//    @Autowired
-//    private SysUserFeignService sysUserFeignService;
-//
-//    @ApiOperation(value = "新增")
-//    @RequestMapping("sysSuggestion/add")
-//    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/add')")
-//    public Object add(SysSuggestion sysSuggestion) {
-//        SysUser sysUser = sysUserFeignService.queryUserInfo();
-//        if (sysUser == null) {
-//            return failed("用户信息获取失败");
-//        }
-//        sysSuggestion.setUserId(sysUser.getId().longValue());
-//        sysSuggestion.setClientType("TEACHER");
-//        if(StringUtils.isEmpty(sysSuggestion.getMobileNo())){
-//            sysSuggestion.setMobileNo(sysUser.getPhone());
-//        }
-//        sysSuggestionService.insert(sysSuggestion);
-//        return succeed();
-//    }
-//
-//    @ApiOperation(value = "删除")
-//    @RequestMapping("sysSuggestion/del")
-//    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/del')")
-//    public Object del(Long id) {
-//        sysSuggestionService.delete(id);
-//        return succeed();
-//    }
-//
-//    @ApiOperation(value = "分页查询")
-//    @RequestMapping("sysSuggestion/queryPage")
-//    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/queryPage')")
-//    public Object queryPage(SysSuggestionQueryInfo queryInfo) {
-//        return succeed(sysSuggestionService.queryPage(queryInfo));
-//    }
+    @Autowired
+    private SysSuggestionService sysSuggestionService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @ApiOperation(value = "新增")
+    @RequestMapping("sysSuggestion/add")
+    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/add')")
+    public Object add(SysSuggestion sysSuggestion) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        sysSuggestion.setUserId(sysUser.getId().longValue());
+        sysSuggestion.setClientType("TEACHER");
+        if(StringUtils.isEmpty(sysSuggestion.getMobileNo())){
+            sysSuggestion.setMobileNo(sysUser.getPhone());
+        }
+        sysSuggestionService.insert(sysSuggestion);
+        return succeed();
+    }
+
+    @ApiOperation(value = "删除")
+    @RequestMapping("sysSuggestion/del")
+    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/del')")
+    public Object del(Long id) {
+        sysSuggestionService.delete(id);
+        return succeed();
+    }
+
+    @ApiOperation(value = "分页查询")
+    @RequestMapping("sysSuggestion/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('sysSuggestion/queryPage')")
+    public Object queryPage(SysSuggestionQueryInfo queryInfo) {
+        return succeed(sysSuggestionService.queryPage(queryInfo));
+    }
 
 }

+ 117 - 71
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/SysSuggestion.java

@@ -1,89 +1,135 @@
 package com.yonge.cooleshow.biz.dal.entity;
 
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
-import java.io.Serializable;
-import java.util.Date;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
+import com.yonge.cooleshow.biz.dal.enums.SuggestionType;
+import com.yonge.cooleshow.common.entity.BaseEntity;
 
 /**
- * 平台建议表
- * 2023-12-20 11:27:10
+ * 对应数据库表(sys_suggestion):
  */
-@Data
-@ApiModel(" SysSuggestion-平台建议表")
-@TableName("sys_suggestion")
-public class SysSuggestion implements Serializable {
+public class SysSuggestion extends BaseEntity {
 
-	@ApiModelProperty("编号")
-	@TableId(value = "id_")
+	/** 编号 */
 	private Long id;
-
-	@ApiModelProperty("联系方式")
-	@TableField(value = "mobile_no_")
+	
+	/** 联系方式 */
+	@ApiModelProperty(value = "联系方式",required = false)
 	private String mobileNo;
-
-	@ApiModelProperty("标题")
-	@TableField(value = "title_")
+	
+	/** 标题 */
+	@ApiModelProperty(value = "标题",required = false)
 	private String title;
-
-	@ApiModelProperty("内容")
-	@TableField(value = "content_")
+	
+	/** 内容 */
+	@ApiModelProperty(value = "内容",required = false)
 	private String content;
 
-	@TableField(value = "url_")
+	/** 媒体 */
+	@ApiModelProperty(value = "媒体",required = false)
 	private String url;
-
-	@ApiModelProperty("用户编号")
-	@TableField(value = "user_id_")
+	
+	/** 用户编号 */
+	@ApiModelProperty(value = "用户编号",required = false)
 	private Long userId;
-
-	@ApiModelProperty("提交时间")
-	@TableField(value = "create_time_")
-	private Date createTime;
-
-	@TableField(value = "client_id_")
-	private String clientId;
-
-	@ApiModelProperty("建议类型")
-	@TableField(value = "type_")
-	private String type;
-
-	@TableField(value = "client_type_")
+	
+	@ApiModelProperty(value = "客户端类型",required = false)
 	private String clientType;
 
-	@ApiModelProperty("建议类型ID")
-	@TableField(value = "suggestion_type_id_")
-	private Long suggestionTypeId;
-
-	@ApiModelProperty("客户端信息")
-	@TableField(value = "user_agent_")
-	private String userAgent;
-
-	@ApiModelProperty("处理状态:true:已处理,false:待处理")
-	@TableField(value = "handle_status_")
-	private Boolean handleStatus;
-
-	@ApiModelProperty("处理时间")
-	@TableField(value = "handle_time_")
-	private Date handleTime;
-
-	@ApiModelProperty("处理人")
-	@TableField(value = "handle_by_")
-	private Long handleBy;
-
-	@ApiModelProperty("是否反馈用户,true:是,false:否")
-	@TableField(value = "feedback_")
-	private Boolean feedback;
-
-	@ApiModelProperty("反馈内容")
-	@TableField(value = "feedback_content_")
-	private String feedbackContent;
-
-}
+	@ApiModelProperty(value = "建议类型")
+	private SuggestionType type = SuggestionType.APP;
+
+	@ApiModelProperty(value = "用户名",required = false)
+	private String username;
+	
+	/** 提交时间 */
+	private java.util.Date createTime;
+
+	public String getUrl() {
+		return url;
+	}
+
+	public void setUrl(String url) {
+		this.url = url;
+	}
+
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	public void setId(Long id){
+		this.id = id;
+	}
+	
+	public Long getId(){
+		return this.id;
+	}
+			
+	public void setMobileNo(String mobileNo){
+		this.mobileNo = mobileNo;
+	}
+	
+	public String getMobileNo(){
+		return this.mobileNo;
+	}
+			
+	public void setTitle(String title){
+		this.title = title;
+	}
+	
+	public String getTitle(){
+		return this.title;
+	}
+			
+	public void setContent(String content){
+		this.content = content;
+	}
+	
+	public String getContent(){
+		return this.content;
+	}
+			
+	public void setUserId(Long userId){
+		this.userId = userId;
+	}
+	
+	public Long getUserId(){
+		return this.userId;
+	}
+			
+	public String getClientType() {
+		return clientType;
+	}
+
+	public void setClientType(String clientType) {
+		this.clientType = clientType;
+	}
+
+	public SuggestionType getType() {
+		return type;
+	}
+
+	public void setType(SuggestionType type) {
+		this.type = type;
+	}
+
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 0 - 28
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/SysSuggestionMapper.java

@@ -1,28 +0,0 @@
-package com.yonge.cooleshow.biz.dal.mapper;
-
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.yonge.cooleshow.biz.dal.entity.SysSuggestion;
-import com.yonge.cooleshow.biz.dal.wrapper.SysSuggestionWrapper;
-import org.apache.ibatis.annotations.Param;
-import org.springframework.stereotype.Repository;
-
-import java.util.List;
-
-/**
- * 平台建议表
- * 2023-12-20 11:27:10
- */
-@Repository
-public interface SysSuggestionMapper extends BaseMapper<SysSuggestion> {
-
-    /**
-     * 分页查询
-     * @param page IPage<SysSuggestionWrapper.SysSuggestion>
-     * @param param SysSuggestionWrapper.SysSuggestionQuery
-     * @return List<SysSuggestionWrapper.SysSuggestion>
-     */
-    List<SysSuggestionWrapper.SysSuggestion> selectPage(@Param("page") IPage<SysSuggestionWrapper.SysSuggestion> page, @Param("param") SysSuggestionWrapper.SysSuggestionQuery param);
-
-}

+ 2 - 40
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/SysSuggestionService.java

@@ -1,46 +1,8 @@
 package com.yonge.cooleshow.biz.dal.service;
 
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.entity.SysSuggestion;
-import com.yonge.cooleshow.biz.dal.wrapper.SysSuggestionWrapper;
-
-/**
- * 平台建议表
- * 2023-12-20 11:27:10
- */
-public interface SysSuggestionService extends IService<SysSuggestion> {
-
-    /**
-     * 查询详情
-     * @param id 详情ID
-     * @return SysSuggestion
-     */
-    SysSuggestion detail(Long id);
-
-    /**
-     * 分页查询
-     * @param page IPage<SysSuggestion>
-     * @param query SysSuggestionWrapper.SysSuggestionQuery
-     * @return IPage<SysSuggestion>
-     */
-    IPage<SysSuggestionWrapper.SysSuggestion> selectPage(IPage<SysSuggestionWrapper.SysSuggestion> page, SysSuggestionWrapper.SysSuggestionQuery query);
-
-    /**
-     * 添加
-     * @param sysSuggestion SysSuggestionWrapper.SysSuggestion
-     * @return Boolean
-     */
-    Boolean add(SysSuggestionWrapper.SysSuggestion sysSuggestion);
-
-    /**
-     * 更新
-     * @param sysSuggestion SysSuggestionWrapper.SysSuggestion
-     * @return Boolean
-     */
-    Boolean update(SysSuggestionWrapper.SysSuggestion sysSuggestion);
+import com.yonge.toolset.mybatis.service.BaseService;
 
-    Boolean handleSuggestion(SysSuggestionWrapper.HandleSuggestion handleSuggestion);
+public interface SysSuggestionService extends BaseService<Long, SysSuggestion> {
 
 }

+ 13 - 88
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/SysSuggestionServiceImpl.java

@@ -1,98 +1,23 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
-import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.microsvc.toolkit.common.webportal.exception.BizException;
-import com.yonge.cooleshow.biz.dal.entity.SysSuggestion;
-import com.yonge.cooleshow.biz.dal.mapper.SysSuggestionMapper;
-import com.yonge.cooleshow.biz.dal.service.SysSuggestionService;
-import com.yonge.cooleshow.biz.dal.wrapper.SysSuggestionWrapper;
+import com.yonge.toolset.mybatis.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Date;
+import com.yonge.cooleshow.biz.dal.dao.SysSuggestionDao;
+import com.yonge.cooleshow.biz.dal.entity.SysSuggestion;
+import com.yonge.cooleshow.biz.dal.service.SysSuggestionService;
+import com.yonge.toolset.mybatis.dal.BaseDAO;
 
-/**
- * 平台建议表
- * 2023-12-20 11:27:10
- */
-@Slf4j
 @Service
-public class SysSuggestionServiceImpl extends ServiceImpl<SysSuggestionMapper, SysSuggestion> implements SysSuggestionService {
-
-	/**
-	 * 查询详情
-	 * @param id 详情ID
-	 * @return SysSuggestion
-	 */
-	@Override
-	public SysSuggestion detail(Long id) {
-
-		return baseMapper.selectById(id);
-	}
-
-	/**
-	 * 分页查询
-	 * @param page IPage<SysSuggestion>
-	 * @param query SysSuggestionWrapper.SysSuggestionQuery
-	 * @return IPage<SysSuggestion>
-	 */
-	@Override
-	public IPage<SysSuggestionWrapper.SysSuggestion> selectPage(IPage<SysSuggestionWrapper.SysSuggestion> page, SysSuggestionWrapper.SysSuggestionQuery query) {
-
-		return page.setRecords(baseMapper.selectPage(page, query));
-	}
-
-	/**
-	 * 添加
-	 * @param sysSuggestion SysSuggestionWrapper.SysSuggestion
-	 * @return Boolean
-	 */
-	@Override
-	public Boolean add(SysSuggestionWrapper.SysSuggestion sysSuggestion) {
-
-		return this.save(JSON.parseObject(sysSuggestion.jsonString(), SysSuggestion.class));
-	}
-
-	/**
-	 * 更新
-	 * @param sysSuggestion SysSuggestionWrapper.SysSuggestion
-	 * @return Boolean
-	 */
-	@Override
-	public Boolean update(SysSuggestionWrapper.SysSuggestion sysSuggestion){
-
-		return this.updateById(JSON.parseObject(sysSuggestion.jsonString(), SysSuggestion.class));
-	}
+public class SysSuggestionServiceImpl extends BaseServiceImpl<Long, SysSuggestion> implements SysSuggestionService {
+	
+	@Autowired
+	private SysSuggestionDao sysSuggestionDao;
 
-	/**
-	 * 处理反馈意见
-	 * @param handleSuggestion handleSuggestion
-	 * @return true/false
-	 */
-	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public Boolean handleSuggestion(SysSuggestionWrapper.HandleSuggestion handleSuggestion) {
-		Long id = handleSuggestion.getId();
-		SysSuggestion suggestion = this.getById(id);
-		if (suggestion == null) {
-			throw new BizException("反馈意见不存在");
-		}
-		Boolean handleStatus = suggestion.getHandleStatus();
-		if (Boolean.TRUE.equals(handleStatus)) {
-			throw new BizException("反馈意见已经处理");
-		}
-		this.lambdaUpdate()
-				.set(SysSuggestion::getHandleStatus, true)
-				.set(SysSuggestion::getHandleTime, new Date())
-				.set(SysSuggestion::getFeedback, handleSuggestion.getFeedback())
-				.set(SysSuggestion::getFeedbackContent, handleSuggestion.getFeedbackContent())
-				.set(SysSuggestion::getHandleBy,handleSuggestion.getHandleBy())
-				.eq(SysSuggestion::getId, handleSuggestion.getId())
-				.eq(SysSuggestion::getHandleStatus, false)
-				.update();
-		return true;
+	public BaseDAO<Long, SysSuggestion> getDAO() {
+		return sysSuggestionDao;
 	}
+	
 }

+ 92 - 62
cooleshow-user/user-biz/src/main/resources/config/mybatis/SysSuggestionMapper.xml

@@ -1,82 +1,112 @@
 <?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.yonge.cooleshow.biz.dal.mapper.SysSuggestionMapper">
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.yonge.cooleshow.biz.dal.dao.SysSuggestionDao">
 
+    <resultMap type="com.yonge.cooleshow.biz.dal.entity.SysSuggestion" id="SysSuggestion">
+        <result column="id_" property="id"/>
+        <result column="mobile_no_" property="mobileNo"/>
+        <result column="title_" property="title"/>
+        <result column="content_" property="content"/>
+        <result column="url_" property="url"/>
+        <result column="user_id_" property="userId"/>
+        <result column="username_" property="username"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="client_type_" property="clientType"/>
+        <result column="type_" property="type" typeHandler="com.yonge.toolset.mybatis.dal.CustomEnumTypeHandler"/>
+    </resultMap>
 
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="SysSuggestion">
+		SELECT * FROM sys_suggestion WHERE id_ = #{id}
+	</select>
 
-    <!-- 表字段 -->
-    <sql id="baseColumns">
-        t.id_ AS id
-        , t.mobile_no_ AS mobileNo
-        , t.title_ AS title
-        , t.content_ AS content
-        , t.url_ AS url
-        , t.user_id_ AS userId
-        , t.create_time_ AS createTime
-        , t.client_id_ AS clientId
-        , t.type_ AS type
-        , t.client_type_ AS clientType
-        , t.suggestion_type_id_ AS suggestionTypeId
-        , t.user_agent_ AS userAgent
-        , t.handle_status_ AS handleStatus
-        , t.handle_time_ AS handleTime
-        , t.handle_by_ AS handleBy
-        , t.feedback_ AS feedback
-        , t.feedback_content_ AS feedbackContent
-    </sql>
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="SysSuggestion">
+		SELECT * FROM sys_suggestion ORDER BY id_
+	</select>
 
-    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.SysSuggestionWrapper$SysSuggestion">
-        SELECT
-        <include refid="baseColumns" />
-        ,CASE WHEN (t.client_type_='STUDENT' or t.client_type_ = 'TENANT_STUDENT') THEN su.username_ ELSE su.real_name_ END nickname
-        ,sst.name_ as suggestionTypeName
-        FROM sys_suggestion t
-        LEFT JOIN sys_user su ON su.id_ = t.user_id_
-        LEFT JOIN sys_suggestion_type sst on t.suggestion_type_id_ = sst.id_
-        <where>
-            su.del_flag_ = 0
-            <if test="param.keyword!=null and param.keyword.trim()!=''">
-                AND (
-                su.real_name_ LIKE CONCAT('%', #{param.keyword}, '%')
-                OR su.username_ LIKE CONCAT('%', #{search}, '%')
-<!--                OR t.user_id_=#{search} OR su.phone_=#{search}-->
-                )
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert" parameterType="com.yonge.cooleshow.biz.dal.entity.SysSuggestion" useGeneratedKeys="true" keyColumn="id"
+            keyProperty="id">
+        INSERT INTO sys_suggestion (mobile_no_,title_,content_,user_id_,create_time_,client_type_,type_,url_)
+        VALUES(#{mobileNo},#{title},#{content},#{userId},now(),#{clientType},#{type, typeHandler=com.yonge.toolset.mybatis.dal.CustomEnumTypeHandler},#{url})
+    </insert>
+
+    <!-- 根据主键查询一条记录 -->
+    <update id="update" parameterType="com.yonge.cooleshow.biz.dal.entity.SysSuggestion">
+        UPDATE sys_suggestion
+        <set>
+            <if test="url != null">
+                url_ = #{url},
             </if>
-            <if test="param.type != null">
-                AND t.type_ = #{param.type}
+            <if test="clientType != null">
+                client_type_ = #{clientType},
             </if>
-            <if test="param.clientType != null">
-                AND t.client_type_ = #{param.clientType}
+            <if test="userId != null">
+                user_id_ = #{userId},
             </if>
-            <if test="param.startTime!=null">
-                AND t.create_time_ >= #{param.startTime}
+            <if test="title != null">
+                title_ = #{title},
             </if>
-            <if test="param.endTime!=null">
-                AND #{param.endTime} >= t.create_time_
+            <if test="content != null">
+                content_ = #{content},
             </if>
-            <if test="param.suggestionTypeId != null">
-                AND t.suggestion_type_id_ = #{param.suggestionTypeId}
+            <if test="mobileNo != null">
+                mobile_no_ = #{mobileNo},
             </if>
-            <if test="param.suggestionTypeName != null and param.suggestionTypeName.trim() != ''">
-                AND sst.name_ = #{param.suggestionTypeName}
+            <if test="type != null">
+                type_ = #{type, typeHandler=com.yonge.toolset.mybatis.dal.CustomEnumTypeHandler},
             </if>
-            <if test="param.handleStatus != null">
-                AND t.handle_status_ = #{param.handleStatus}
+        </set>
+        WHERE id_ = #{id} 
+    </update>
+
+    <!-- 根据主键删除一条记录 -->
+    <delete id="delete">
+		DELETE FROM sys_suggestion WHERE id_ = #{id} 
+	</delete>
+
+    <sql id="queryCondition">
+        <where>
+            su.del_flag_ = 0
+            <if test="type!=null">
+                AND ss.type_ = #{type, typeHandler=com.yonge.toolset.mybatis.dal.CustomEnumTypeHandler}
             </if>
-            <if test="param.handleBy != null">
-                AND t.handle_by_ = #{param.handleBy}
+            <if test="clientType!=null">
+                AND ss.client_type_ = #{clientType}
             </if>
-            <if test="param.handStartTime != null">
-                AND t.handle_time_ >= #{param.handStartTime}
+            <if test="startTime!=null and startTime!=''">
+                AND DATE_FORMAT(ss.create_time_,'%Y-%m-%d') &gt;= #{startTime}
             </if>
-            <if test="param.handEndTime != null">
-                AND #{param.handEndTime} >= t.handle_time_
+            <if test="endTime!=null and endTime!=''">
+                AND DATE_FORMAT(ss.create_time_,'%Y-%m-%d') &lt;= #{endTime}
             </if>
-            <if test="param.feedback != null">
-                AND t.feedback_ = #{param.feedback}
+            <if test="search!=null and search!=''">
+                AND (su.real_name_ LIKE CONCAT('%', #{search}, '%') OR su.username_ LIKE CONCAT('%', #{search}, '%') OR ss.user_id_=#{search} OR su.phone_=#{search})
             </if>
         </where>
-        ORDER BY t.id_ DESC
+    </sql>
+
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="SysSuggestion" parameterType="map">
+        SELECT ss.*,
+        CASE WHEN (ss.client_type_='STUDENT' or ss.client_type_ = 'TENANT_STUDENT') THEN su.username_ ELSE su.real_name_ END
+        username_
+        FROM sys_suggestion ss
+        LEFT JOIN sys_user su ON su.id_ = ss.user_id_
+        <include refid="queryCondition" />
+        ORDER BY ss.id_ DESC
+        <include refid="global.limit"/>
     </select>
 
-</mapper>
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+		SELECT COUNT(ss.id_) FROM sys_suggestion ss
+        LEFT JOIN sys_user su ON su.id_ = ss.user_id_
+        <include refid="queryCondition" />
+	</select>
+</mapper>

+ 1 - 1
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/SysSuggestionController.java

@@ -48,7 +48,7 @@ public class SysSuggestionController extends BaseController {
             sysSuggestion.setClientType(ClientEnum.TENANT_STUDENT.getCode());
         }
 
-        sysSuggestionService.save(sysSuggestion);
+        sysSuggestionService.insert(sysSuggestion);
         return succeed();
     }
 

+ 1 - 1
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/SysSuggestionController.java

@@ -36,7 +36,7 @@ public class SysSuggestionController extends BaseController {
         if(StringUtils.isEmpty(sysSuggestion.getMobileNo())){
             sysSuggestion.setMobileNo(sysUser.getPhone());
         }
-        sysSuggestionService.save(sysSuggestion);
+        sysSuggestionService.insert(sysSuggestion);
         return succeed();
     }