wsl il y a 2 ans
Parent
commit
040fe2eabf

+ 27 - 1
common/common-entity/sql记录

@ -2182,4 +2182,30 @@ CREATE TABLE `base_daily_urging_record` (
  `create_user_name` varchar(50) DEFAULT NULL,
  `create_user_name` varchar(50) DEFAULT NULL,
  `del` tinyint(2) DEFAULT NULL COMMENT '1有效0无效',
  `del` tinyint(2) DEFAULT NULL COMMENT '1有效0无效',
  PRIMARY KEY (`id`)
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--2022-09-06 wsl
CREATE TABLE `base_opinion_feedback` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `suggest_user_id` varchar(50) DEFAULT NULL COMMENT '反馈用户',
  `suggest_user_name` varchar(50) DEFAULT NULL COMMENT '反馈用户名字',
  `user_type` int(2) DEFAULT NULL COMMENT '反馈用户类型 0家属 1社工 2助老员',
  `feedback_type` int(2) DEFAULT NULL COMMENT '反馈工单类型',
  `suggest_describe` varchar(50) DEFAULT NULL COMMENT '反馈内容',
  `suggest_user_phone` varchar(20) DEFAULT NULL COMMENT '反馈人手机号',
  `suggest_status` int(2) DEFAULT NULL COMMENT '反馈状态 0处理中 1已回复',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '反馈时间',
  `manager_res` varchar(500) DEFAULT NULL COMMENT '回复内容',
  `reply_time` timestamp NULL DEFAULT NULL COMMENT '回复时间',
  `suggest_img_url` varchar(2500) DEFAULT NULL COMMENT '图片地址“,”分割',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4 COMMENT='医养意见反馈表';
ALTER table wlyy_user_role add COLUMN `del` int(1) DEFAULT NULL COMMENT '是否生效';
INSERT INTO `base`.`wlyy_hospital_sys_dict`(`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('opinionFeedback1', NULL, 'opinionFeedbackType', '1', '功能异常', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `base`.`wlyy_hospital_sys_dict`(`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('opinionFeedback2', NULL, 'opinionFeedbackType', '2', '功能优化', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `base`.`wlyy_hospital_sys_dict`(`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('opinionFeedback3', NULL, 'opinionFeedbackType', '3', '功能建议', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `base`.`wlyy_hospital_sys_dict`(`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('opinionFeedback4', NULL, 'opinionFeedbackType', '4', '其他', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

+ 12 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/role/WlyyUserRole.java

@ -21,6 +21,18 @@ public class WlyyUserRole extends IdEntity {
    private String role;    // 角色编码
    private String role;    // 角色编码
    private String czy;     // 操作员
    private String czy;     // 操作员
    private Date czrq;      // 操作日期
    private Date czrq;      // 操作日期
    private Integer del;  //是否生效  2022-09-08 添加
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "user")
    @Column(name = "user")
    public String getUser() {
    public String getUser() {

+ 170 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/patient/BaseOpinionFeedBackEntity.java

@ -0,0 +1,170 @@
package com.yihu.jw.entity.patient;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by wsl on 2022/9/6
 */
@Entity
@Table(name = "base_opinion_feedback")
public class BaseOpinionFeedBackEntity extends IdEntity {
    /**
     * 反馈用户
     */
    private String suggestUserId;
    /**
     * 反馈用户名字
     */
    private String suggestUserName;
    /**
     * 反馈用户类型 0家属 1社工 2助老员
     */
    private Integer userType;
    /**
     * 反馈工单类型
     */
    private Integer feedbackType;
    /**
     * 反馈内容
     */
    private String suggestDescribe;
    /**
     * 反馈人手机号
     */
    private String suggestUserPhone;
    /**
     * 反馈状态 0处理中 1已回复
     */
    private Integer suggestStatus;
    /**
     * 反馈时间
     */
    private Date createTime;
    /**
     * 回复内容
     */
    private String managerRes;
    /**
     * 回复时间
     */
    private Date replyTime;
    /**
     * 图片地址“,”分割
     */
    private String suggestImgUrl;
    @Column(name = "suggest_user_id")
    public String getSuggestUserId() {
        return suggestUserId;
    }
    public void setSuggestUserId(String suggestUserId) {
        this.suggestUserId = suggestUserId;
    }
    @Column(name = "suggest_user_name")
    public String getSuggestUserName() {
        return suggestUserName;
    }
    public void setSuggestUserName(String suggestUserName) {
        this.suggestUserName = suggestUserName;
    }
    @Column(name = "user_type")
    public Integer getUserType() {
        return userType;
    }
    public void setUserType(Integer userType) {
        this.userType = userType;
    }
    @Column(name = "feedback_type")
    public Integer getFeedbackType() {
        return feedbackType;
    }
    public void setFeedbackType(Integer feedbackType) {
        this.feedbackType = feedbackType;
    }
    @Column(name = "suggest_describe")
    public String getSuggestDescribe() {
        return suggestDescribe;
    }
    public void setSuggestDescribe(String suggestDescribe) {
        this.suggestDescribe = suggestDescribe;
    }
    @Column(name = "suggest_user_phone")
    public String getSuggestUserPhone() {
        return suggestUserPhone;
    }
    public void setSuggestUserPhone(String suggestUserPhone) {
        this.suggestUserPhone = suggestUserPhone;
    }
    @Column(name = "suggest_status")
    public Integer getSuggestStatus() {
        return suggestStatus;
    }
    public void setSuggestStatus(Integer suggestStatus) {
        this.suggestStatus = suggestStatus;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "manager_res")
    public String getManagerRes() {
        return managerRes;
    }
    public void setManagerRes(String managerRes) {
        this.managerRes = managerRes;
    }
    @Column(name = "reply_time")
    public Date getReplyTime() {
        return replyTime;
    }
    public void setReplyTime(Date replyTime) {
        this.replyTime = replyTime;
    }
    @Column(name = "suggest_img_url")
    public String getSuggestImgUrl() {
        return suggestImgUrl;
    }
    public void setSuggestImgUrl(String suggestImgUrl) {
        this.suggestImgUrl = suggestImgUrl;
    }
}

+ 12 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/patient/BaseOpinionFeedbackDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.base.dao.patient;
import com.yihu.jw.entity.patient.BaseOpinionFeedBackEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by wsl on 2022/9/6
 */
public interface BaseOpinionFeedbackDao extends JpaRepository<BaseOpinionFeedBackEntity,String>, JpaSpecificationExecutor<BaseOpinionFeedBackEntity> {
}

+ 108 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/customerService/CustomerServiceController.java

@ -0,0 +1,108 @@
package com.yihu.jw.base.endpoint.customerService;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.service.customerService.CustomerService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
 * Created by wsl on 2022/9/7
 */
@RestController
@RequestMapping(value = "CustomerService/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(value = "客服管理", description = "客服管理接口", tags = {"wlyy基础服务 - 客服管理"})
public class CustomerServiceController extends EnvelopRestEndpoint {
    @Autowired
    private CustomerService customerService;
    @GetMapping("findByCustomerService")
    @ApiOperation("获取所有客服")
    public ObjEnvelop findByCustomerService(@RequestParam(value = "name",required = false) String name,
                                             @RequestParam(value = "page") Integer page,
                                             @RequestParam(value = "pageSize") Integer pageSize){
        try {
            JSONObject byCustomerService = customerService.findByCustomerService(name, page, pageSize);
            return success(byCustomerService);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("服务端异常");
        }
    }
    @GetMapping("findByUserPhone")
    @ApiOperation("查找用户")
    public ObjEnvelop findByUserPhone(@RequestParam(value = "phone") String phone) {
        try {
            Map byUserPhone = customerService.findByUserPhone(phone);
            if (byUserPhone != null) {
                return ObjEnvelop.getSuccess("查找成功", byUserPhone, 200);
            } else {
                return ObjEnvelop.getError("查找失败", 400);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("服务端异常");
        }
    }
    @PostMapping("addCustomerServiceUser")
    @ApiOperation("添加客服")
    public Envelop addCustomerServiceUser(@RequestParam(value = "id") String id) {
        try {
            Integer result = customerService.addCustomerServiceUser(id);
           if (result == 0){
                return Envelop.getError("添加失败!当前已存在一个生效客服!",500);
            }else if (result == -1){
                return Envelop.getError("添加失败!当前客服已存在未生效状态!",500);
            }else {
               return success("添加成功");
           }
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("服务端异常");
        }
    }
    @PostMapping("invalidCustomerService")
    @ApiOperation("失效/生效客服")
    public Envelop invalidCustomerService(@RequestParam(value = "id") String id,
                                          @RequestParam(value = "status") Integer status){
        try {
            Integer result = customerService.invalidCustomerService(id, status);
            if (-1==result){
                return Envelop.getError("已存在一个生效客服!");
            }
            return success("修改成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("服务端异常");
        }
    }
    @PostMapping("delCustomerService")
    @ApiOperation("删除客服")
    public Envelop delCustomerService(@RequestParam(value = "id") String id){
        try {
            customerService.delCustomerService(id);
            return success("删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("服务端异常");
        }
    }
}

+ 65 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/opinionFeedback/OpinionFeedbackController.java

@ -0,0 +1,65 @@
package com.yihu.jw.base.endpoint.opinionFeedback;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.service.opinionFeedback.OpinionFeedbackService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Created by wsl on 2022/9/7
 */
@RestController
@RequestMapping(value = "suggestionManage/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(value = "意见反馈", description = "意见反馈接口", tags = {"wlyy基础服务 - 意见反馈管理"})
public class OpinionFeedbackController extends EnvelopRestEndpoint {
    @Autowired
    private OpinionFeedbackService opinionFeedbackService;
    @GetMapping("findOpinionFeedbackList")
    @ApiOperation("查找列表")
    public ObjEnvelop findOpinionFeedbackList(@RequestParam(value = "suggestUserName", required = false) String suggestUserName,
                                              @RequestParam(value = "feedbcakType", required = false) Integer feedbcakType,
                                              @RequestParam(value = "userType", required = false) Integer userType,
                                              @RequestParam(value = "suggestStatus", required = false) Integer suggestStatus,
                                              @RequestParam(value = "page", required = false) Integer page,
                                              @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                              @RequestParam(value = "id", required = false) String id) {
        try {
            JSONObject opinionFeedbackList = opinionFeedbackService.findOpinionFeedbackList(suggestUserName, feedbcakType, userType, suggestStatus, page, pageSize, id);
            return success(opinionFeedbackList);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("服务端异常");
        }
    }
    @PostMapping("saveReply")
    @ApiOperation("保存回复")
    public Envelop saveReply(@RequestParam(value = "id", required = false) Integer id,
                             @RequestParam(value = "managerRes", required = false) String managerRes) {
        try {
            Integer result = opinionFeedbackService.saveReply(id, managerRes);
            if (result==-1) {
                return Envelop.getError("该反馈已回复,请勿重复回复");
            }else{
                return success("保存成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("服务端异常");
        }
    }
}

+ 91 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/customerService/CustomerService.java

@ -0,0 +1,91 @@
package com.yihu.jw.base.service.customerService;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
 * Created by wsl on 2022/9/7
 */
@Service
public class CustomerService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public JSONObject findByCustomerService(String name, Integer page, Integer pageSize) {
        JSONObject result = new JSONObject();
        String sql = "SELECT d.id,d.name,d.idcard,d.mobile,r.del AS `status` FROM base_doctor d INNER JOIN wlyy_user_role r ON d.id = r.`user` " +
                " WHERE 1=1 AND d.del = 1 AND r.role = 'chjd_kf'";
        String sqlTotal = "SELECT count(d.id) FROM base_doctor d INNER JOIN wlyy_user_role r ON d.id = r.`user` " +
                " WHERE 1=1 AND d.del = 1 AND r.role = 'chjd_kf'";
        if (StringUtils.isNotBlank(name)) {
            sql += " and d.name like '%" + name + "%'";
            sqlTotal += " and d.name like '%" + name + "%'";
        }
        sql += "limit " + page + "," + pageSize + "";
        Integer total = jdbcTemplate.queryForObject(sqlTotal, Integer.class);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        result.put("total",total);
        result.put("data",list);
        return result;
    }
    //查询用户
    public Map findByUserPhone(String phone) {
        String sql = "select id,name,idcard,mobile  from base_doctor where mobile = '" + phone + "' and del = 1";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        if (list.size() > 0) {
            return list.get(0);
        }
        return null;
    }
    //添加客服
    @Transactional(rollbackFor = Exception.class)
    public Integer addCustomerServiceUser(String id) {
        String sql = "select count(id) from wlyy_user_role where del = 1";
        String sqldel = "select count(id) from wlyy_user_role where user ='" + id + "' and del = 0";
        Integer total = jdbcTemplate.queryForObject(sql, Integer.class);
        Integer delTotal = jdbcTemplate.queryForObject(sqldel, Integer.class);
        if (total > 0) return 0;
        if (delTotal > 0) return -1;
        String instSql = "INSERT INTO `base`.`wlyy_user_role`(`user`, `role`, `czy`, `czrq`,`del`) VALUES ('" + id + "', 'chjd_kf', NULL, NULL,1);";
        jdbcTemplate.update(instSql);
        return 1;
    }
    @Transactional(rollbackFor = Exception.class)
    public Integer invalidCustomerService(String id, Integer status) {
        if (1 == status) {
            String sqlTotal = "select count(id) from wlyy_user_role where 1=1 and role = 'chjd_kf' and del=1";
            Integer total = jdbcTemplate.queryForObject(sqlTotal, Integer.class);
            if (total > 1) return -1;
        }
        String sql = "update wlyy_user_role set del = '" + status + "' where user = '" + id + "' and role ='chjd_kf' ";
        jdbcTemplate.update(sql);
        return 1;
    }
    @Transactional(rollbackFor = Exception.class)
    public void delCustomerService(String id) {
        String sql = "delete from wlyy_user_role where user = '" + id + "' and role ='chjd_kf' ";
        jdbcTemplate.execute(sql);
    }
}

+ 104 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/opinionFeedback/OpinionFeedbackService.java

@ -0,0 +1,104 @@
package com.yihu.jw.base.service.opinionFeedback;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.patient.BaseOpinionFeedBackEntity;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
 * Created by wsl on 2022/9/6
 */
@Service
public class OpinionFeedbackService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public JSONObject findOpinionFeedbackList(String suggestUserName, Integer feedbcakType, Integer userType, Integer suggestStatus, Integer page, Integer pageSize,String id) {
        JSONObject jsonObject = new JSONObject();
        String sql = "select id,suggest_user_id as suggestUserId,suggest_user_name as suggestUserName,user_type as userType," +
                "feedback_type as feedbackType,suggest_describe as suggestDescribe,suggest_user_phone as suggestUserPhone," +
                "suggest_status as suggestStatus,create_time as createTime,manager_res as managerRes,reply_time as replyTime," +
                "suggest_img_url as suggestImgUrl from base_opinion_feedback where 1=1 ";
        String sqlTotal = "select count(*) from base_opinion_feedback where 1=1 ";
        if (StringUtils.isNotBlank(suggestUserName)) {
            sql += " and suggest_user_name like '%" + suggestUserName + "%'";
            sqlTotal += " and suggest_user_name like '%" + suggestUserName + "%'";
        }
        if (null != feedbcakType) {
            sql +=" and feedback_type = "+feedbcakType+"";
            sqlTotal +=" and feedback_type = "+feedbcakType+"";
        }
        if (null != userType) {
            sql +=" and  user_type = "+userType+"";
            sqlTotal +=" and  user_type = "+userType+"";
        }
        if (null != suggestStatus) {
            sql +=" and  suggest_status = "+suggestStatus+"";
            sqlTotal +=" and  suggest_status = "+suggestStatus+"";
        }
        if (StringUtils.isNotBlank(id)){
            sql +=" and id = '"+id+"'";
            sqlTotal +=" and id = '"+id+"'";
        }
        sql +=" order by create_time DESC ";
        if (StringUtils.isBlank(id)) {
            if (page == null) {
                page = 0;
            }
            if (pageSize == null) {
                pageSize = 10;
            }
            sql+=" LIMIT "+page+","+pageSize+" ";
        }
        List<BaseOpinionFeedBackEntity> entityList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BaseOpinionFeedBackEntity.class));
        Integer total = jdbcTemplate.queryForObject(sqlTotal, Integer.class);
        jsonObject.put("total",total);
        jsonObject.put("obj",entityList);
        return jsonObject;
    }
   /* public BaseOpinionFeedBackEntity findOpinionFeedback(Integer id){
        String sql = "select * from base_opinion_feedback where id = "+id+"";
        return jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(BaseOpinionFeedBackEntity.class));
    }*/
    @Transactional(rollbackFor = Exception.class)
    public Integer saveReply(Integer id,String managerRes){
        String sql ="select count(id) from base_opinion_feedback where suggest_status = 1 and id = '"+id+"' ";
        Integer total = jdbcTemplate.queryForObject(sql, Integer.class);
        if (total>0){
            return -1;
        }
        String updSql = "UPDATE base_opinion_feedback SET suggest_status = 1, manager_res ='"+managerRes+"',reply_time ='"+DateUtil.dateToStrLong(new Date())+"' WHERE id = '"+id+"'";
        jdbcTemplate.update(updSql);
        return 1;
    }
}

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/patient/BaseOpinionFeedbackDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.care.dao.patient;
import com.yihu.jw.entity.patient.BaseOpinionFeedBackEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by wsl on 2022/9/6
 */
public interface BaseOpinionFeedbackDao extends JpaRepository<BaseOpinionFeedBackEntity,String>, JpaSpecificationExecutor<BaseOpinionFeedBackEntity> {
}

+ 76 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/OpinionFeedback/OpinionFeedbackController.java

@ -0,0 +1,76 @@
package com.yihu.jw.care.endpoint.OpinionFeedback;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.opinion.UserOpinionFeedbackService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by wsl on 2022/9/6
 */
@RestController
@RequestMapping("suggestionManage/")
@Api(tags = "意见反馈")
public class OpinionFeedbackController extends BaseController {
    @Autowired
    UserOpinionFeedbackService userOpinionFeedbackService;
    @RequestMapping(value = "saveSuggestion", method = RequestMethod.POST)
    @ApiOperation(value = "保存 意见反馈")
    public String saveOpinionFeedback(@ApiParam(name = "suggestUserId",value = "反馈人")
                                      @RequestParam(value = "suggestUserId",required = true)String suggestUserId,
                                      @ApiParam(name = "suggestUserName",value = "反馈人名字")
                                      @RequestParam(value = "suggestUserName",required = true)String suggestUserName,
                                      @ApiParam(name = "suggestUserPhone",value = "反馈人手机号")
                                      @RequestParam(value = "suggestUserPhone",required = true)String suggestUserPhone,
                                      @ApiParam(name = "suggestDescribe",value = "反馈内容")
                                      @RequestParam(value = "suggestDescribe")String suggestDescribe,
                                      @ApiParam(name = "userType",value = "反馈人类型 0家属 1社工 2助老员")
                                      @RequestParam(value = "userType")Integer userType,
                                      @ApiParam(name = "suggestImgUrl",value = "附件",required = false)
                                      @RequestParam(value = "suggestImgUrl",required = false)String suggestImgUrl,
                                      @ApiParam(name = "feedBackType",value = "反馈类型",required = true)
                                      @RequestParam(value = "feedBackType",required = true)Integer feedBackType){
        try {
            userOpinionFeedbackService.saveOpinionFeedback(suggestUserId,suggestUserName,suggestUserPhone,suggestDescribe,userType,suggestImgUrl,feedBackType);
            return success("保存成功!");
        } catch (Exception e) {
            error(e);
            return errorResult(e);
        }
    }
    @RequestMapping(value = "findUserOpinioneFeedbackList", method = RequestMethod.POST)
    @ApiOperation(value = "获取意见反馈 列表/详情")
    public ObjEnvelop findUserOpinioneFeedback(@ApiParam(name = "suggestUserId", value = "反馈人")
                                           @RequestParam(value = "suggestUserId", required = false) String suggestUserId,
                                           @ApiParam(name = "id", value = "反馈id",required = false)
                                           @RequestParam(value = "id", required = false) String id,
                                           @RequestParam(value = "page", required = false) Integer page,
                                           @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            JSONObject userOpinioneFeedback = userOpinionFeedbackService.findUserOpinioneFeedback(suggestUserId, id,page,pageSize);
            return ObjEnvelop.getSuccess("获取成功",userOpinioneFeedback,200);
        } catch (Exception e) {
            error(e);
            return ObjEnvelop.getError("服务端异常");
        }
    }
}

+ 67 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/opinion/UserOpinionFeedbackService.java

@ -0,0 +1,67 @@
package com.yihu.jw.care.service.opinion;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.patient.BaseOpinionFeedbackDao;
import com.yihu.jw.entity.patient.BaseOpinionFeedBackEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by wsl on 2022/9/6
 */
@Service
public class UserOpinionFeedbackService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseOpinionFeedbackDao baseOpinionFeedbackDao;
    @Transactional(rollbackFor = Exception.class)
    public void saveOpinionFeedback(String suggestUserId,String suggestUserName,String suggestUserPhone,String suggestDescribe,Integer userType,String suggestImgUrl,Integer feedBackType){
        BaseOpinionFeedBackEntity entity = new BaseOpinionFeedBackEntity();
        entity.setSuggestUserId(suggestUserId);
        entity.setSuggestUserName(suggestUserName);
        entity.setSuggestDescribe(suggestDescribe);
        entity.setUserType(userType);
        entity.setSuggestUserPhone(suggestUserPhone);
        entity.setSuggestStatus(0);
        entity.setCreateTime(new Date());
        entity.setFeedbackType(feedBackType);
        if (StringUtils.isNotBlank(suggestImgUrl))entity.setSuggestImgUrl(suggestImgUrl);
        baseOpinionFeedbackDao.save(entity);
    }
    public JSONObject findUserOpinioneFeedback(String suggestUserId,String id,Integer page,Integer pageSize){
        String sql = "select <word> from base_opinion_feedback where 1=1 ";
        String sqlTotal = "select count(id) from base_opinion_feedback where 1=1 ";
        JSONObject result = new JSONObject();
        if (StringUtils.isNotBlank(id)){
            sql = sql.replace("<word>","id,suggest_user_id as suggestUserId,suggest_user_name as suggestUserName,user_type as userType,feedback_type as feedbackType,suggest_describe as suggestDescribe,suggest_user_phone as suggestUserPhone,suggest_status as suggestStatus,create_time as createTime,manager_res as managerRes,reply_time as replyTime,suggest_img_url as suggestImgUrl");
            sql+=" and id = '"+id+"'";
        }else {
            sql = sql.replace("<word>","id,suggest_describe as suggestDescribe ,suggest_status as suggestStatus ,create_time as createTime ");
            sql+="and suggest_user_id = '"+suggestUserId+"' ";
            sqlTotal+=" and suggest_user_id = '"+suggestUserId+"' ";
            sql+= " order by create_time DESC limit "+page+","+pageSize+" ";
        }
        Integer integer = jdbcTemplate.queryForObject(sqlTotal, Integer.class);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        result.put("total",integer);
        result.put("data",list);
        return result;
    }
}