puzhibing
2023-02-11 521efb9bc33d52ef4772f0b30f8a371ba4b0070c
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TReportLossController.java
@@ -5,6 +5,14 @@
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.model.TUser;
import com.stylefeng.guns.modular.system.service.ITUserService;
import com.stylefeng.guns.modular.system.util.EmailUtil;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -16,6 +24,7 @@
import com.stylefeng.guns.modular.system.model.TReportLoss;
import com.stylefeng.guns.modular.system.service.ITReportLossService;
import java.io.File;
import java.util.Map;
/**
@@ -32,6 +41,12 @@
    @Autowired
    private ITReportLossService tReportLossService;
    @Autowired
    private ITUserService userService;
    @Value("${spring.mail.template-path}")
    private String templatePath;
    /**
     * 跳转到首页
@@ -129,6 +144,22 @@
        tReportLoss.setHandleUserId(ShiroKit.getUser().getObjectId());
        boolean b = tReportLossService.updateById(tReportLoss);
        if(b){
            try {
                TUser userInfo = userService.selectById(tReportLoss.getUserId());
                if(ToolUtil.isNotEmpty(userInfo.getEmail())){
                    String path = templatePath +  "user/reportLossResult.html";
                    Document document = Jsoup.parse(new File(path), "UTF-8");
                    document.getElementById("chinese").attr("style", "display: none;");
                    document.getElementById("french").attr("style", "display: none;");
                    Element english_user = document.getElementById("english_user");
                    english_user.text("Hello " + userInfo.getNickName() + ",");
                    Element english_content = document.getElementById("english_content");
                    english_content.text(info);
                    EmailUtil.send(userInfo.getEmail(), "Notification of the result of the loss report",  document.html());
                }
            }catch (Exception e){
                e.printStackTrace();
            }
            return SUCCESS_TIP;
        }
        return ERROR;